-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGreatest.c
More file actions
46 lines (35 loc) · 934 Bytes
/
Greatest.c
File metadata and controls
46 lines (35 loc) · 934 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
42
43
44
45
46
//This is a program to find the greatest of the two numbers.
#include<stdio.h>
int main ()
{
int num1, num2;
printf ("Insert two numbers: ");
scanf ("%d % d", &num1, &num2);
//Condition to check which of the two numbers is greater
//it will compare numbers where number 1 is greater
if (num1 > num2)
printf ("%d is greatest", num1);
//where number 2 is greater
else if (num1 > num1)
printf ("%d is greatest", num2);
//for both are equal
else
printf ("%d and % d are equal", num1, num2);
return 0;
}
/* This is another method to find the greatest of the two using ternary operator.
#include<stdio.h>
int main ()
{
int num1, num2, largest;
printf ("Insert two numbers: ");
scanf ("%d %d", &num1, &num2);
if(num1 == num2)
printf("Both are Equal\n");
else{
largest = num1 > num2? num1 : num2;
printf("%d is largest",largest);
}
return 0;
}
*/