Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update functions-in-c.c #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions c/functions-in-c.c
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
#include <stdio.h>
#include <stdio.h> //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;
}
}
14 changes: 7 additions & 7 deletions cpp/arrays-introduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}