-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
41 lines (35 loc) · 833 Bytes
/
main.c
File metadata and controls
41 lines (35 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
1) Write and name a function max(), that returns the max value between two arguments.
*/
#include <stdio.h>
int max( int a, int b);
int main() {
int x,y;
int resp;
do{
printf("ENTER A NUMBER : ");
scanf("%d",&x);
printf("ENTER A NUMBER : ");
scanf("%d",&y);
printf("%s %d \n", "THE MAX VALUE IS : ", max(x,y));
printf("DO YOU WANT TO DO A NEW OPERATION 1) -> YES 0) -> NO :");
scanf("%d", &resp);
if(resp != 1 && resp != 0){
printf("%s\n", "INVALID VALUE");
}
}while(resp != 0);
return 0;
}
//max () function.
int max(int a, int b){
int maxValue;
if(a>=b){
maxValue = a;
return maxValue;
} else if (b>=a){
maxValue = b;
return maxValue;
}else{
return 0;
}
}