forked from IT1050-2022-Feb/tutorial-01-IT22323552
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTute04.c
39 lines (29 loc) · 1 KB
/
Tute04.c
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
/*Exercise 4 - Functions
Implement the three functions minimum(), maximum() and multiply() below the
main() function.
Do not change the code given in the main() function when you are implementing
your solution.*/
#include <stdio.h>
int minimum(int a, int b); // minimun function prototype
int maximum(int c, int d); // maximum function prototype
int multiply(int x, int y); // multiply function prototype
int main() {
int no1, no2;
printf("Enter a value for no 1 : ");
scanf("%d", &no1);
printf("Enter a value for no 2 : ");
scanf("%d", &no2);
printf("%d ", minimum(no1, no2));
printf("%d ", maximum(no1, no2));
printf("%d ", multiply(no1, no2));
return 0;
}
int minimum(int a, int b) {
return a > b ? b : a; // returning the minimum number by using the conditional
// operator
}
int maximum(int c, int d) {
return c > d ? c : d; // returning the maxium number by using the conditional
// operator
}
int multiply(int x, int y) { return x * y; }