diff --git a/c/functions-in-c.c b/c/functions-in-c.c index 627efa9..81c7b3a 100644 --- a/c/functions-in-c.c +++ b/c/functions-in-c.c @@ -1,25 +1,27 @@ -#include +#include //headerFile +int max_of_four(int , int , int , int); //function declaration -int max_of_four(int a, int b, int c, int d) +int max_of_four(int a, int b, int c, int d) //function definition { + //body of function int res = a; - + if (b > res) res = b; if (c > res) res = c; if (d > res) res = d; - + return res; } - +//main function int main() { - int a, b, c, d; - scanf("%d %d %d %d", &a, &b, &c, &d); - int ans = max_of_four(a, b, c, d); - printf("%d", ans); - + int num_1, num_2, num_3, num_4; + printf("Enter FOUR numbers : "); + scanf("%d %d %d %d", &num_1, &num_2, &num_3, &num_4); + int answer = max_of_four(num_1, num_2, num_3, num_4); + printf("\nLargest Number is : %d", answer); return 0; -} \ No newline at end of file +} diff --git a/cpp/arrays-introduction.cpp b/cpp/arrays-introduction.cpp index e9691ce..c1da5ea 100644 --- a/cpp/arrays-introduction.cpp +++ b/cpp/arrays-introduction.cpp @@ -7,12 +7,12 @@ using namespace std; int main() { - int N; - int array[1010]; - cin >> N; - for (int i = N; i; i--) - cin >> array[i]; - for (int i = 1; i <= N; i++) - cout << array[i] << " "; + int size; //size variable for size of array + int array[1001]; + cin >> size; + for (int index = size; index; index--) + cin >> array[index]; + for (int index = 1; index <= size; index++) + cout << array[index] << " "; return 0; }