C program to find maximum between two numbers
C program to find maximum between two numbers
Example:
Enter first no: 12
Enter second no: 6
Output: Largest no is = 12
Enjoy it.............
Enter first no: 12
Enter second no: 6
Output: Largest no is = 12
Required knowledge:
Fundamentals of C, Data types, Taking user input in C, IF-elseProgram to find maximum or minimum
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
/*****************************************************
* C program to find maximum between two numbers *
*****************************************************/
#include <stdio.h>
void main()
{
int
num1, num2;
/*
* Reads two integer values from user
*/
printf
(
"Enter first number: "
);
scanf
(
"%d%d"
, &num1);
printf
(
"\nEnter second number: "
);
scanf
(
"%d%d"
, &num2);
/ ***************************
* Compare num1 with num2 *
***************************/
if
(num1 > num2)
{
printf
(
"%d is maximum"
, num1);
}
else
{
printf
(
"%d is maximum"
, num2);
}
}
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
| /***************************************************** * C program to find maximum between two numbers * *****************************************************/ #include <stdio.h>
void
main() { int num1, num2; /* * Reads two integer values from user */ printf ( "Enter first number: " ); scanf ( "%d%d" , &num1);
printf ( "\nEnter second number: " ); scanf ( "%d%d" , &num2); / *************************** * Compare num1 with num2 * ***************************/ if (num1 > num2) { printf ( "%d is maximum" , num1); } else { printf ( "%d is maximum" , num2); } } |
Enjoy it.............
Comments
Post a Comment
Dears! Yours Comment approved in 24 hours also your answer in 24 hours.......