From 521ce5453bb2899bfcdfb74a9d99eff381d287c8 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma <58878438+imgeekabhi@users.noreply.github.com> Date: Thu, 1 Oct 2020 10:23:23 +0530 Subject: [PATCH 1/2] Update functions-in-c.c I wrote a code in a good way that helps other programmers to understand in a better way --- c/functions-in-c.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) 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 +} From 7fe4a308abad85ce446a28328324be480672e6fc Mon Sep 17 00:00:00 2001 From: Abhishek Sharma <58878438+imgeekabhi@users.noreply.github.com> Date: Sun, 11 Oct 2020 14:59:08 +0530 Subject: [PATCH 2/2] Update arrays-introduction.cpp --- cpp/arrays-introduction.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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; }