Biggest of Two Numbers: C


In this video tutorial we ask the user to enter 2 integer numbers and using if else and relational operator we check and display the biggest of 2 numbers on the console.

Related Read:
if else statement in C
Relational Operators In C

C Program To Find Biggest of 2 numbers

  1.    
  2. #include < stdio.h >  
  3.   
  4. int main()  
  5. {  
  6.     int a, b;  
  7.   
  8.     printf("Enter 2 numbers\n");  
  9.     scanf("%d%d", &a, &b);  
  10.   
  11.     if(a > b)  
  12.     {  
  13.         printf("Biggest of %d and %d is %d\n", a, b, a);  
  14.     }  
  15.     else  
  16.     {  
  17.         printf("Biggest of %d and %d is %d\n", a, b, b);  
  18.     }  
  19.   
  20.     return 0;  
  21. }  

Output 1:
Enter 2 numbers
20
30
Biggest of 20 and 30 is 30

Output 2:
Enter 2 numbers
200
300
Biggest of 200 and 300 is 300

Biggest of 2 numbers: C Program



YouTube Link: https://www.youtube.com/watch?v=Bx_aowugT3E [Watch the Video In Full Screen.]


C Program To Find Biggest of 2 numbers

  1.    
  2. #include < stdio.h >  
  3.   
  4. int main()  
  5. {  
  6.     int a, b, big;  
  7.   
  8.     printf("Enter 2 numbers\n");  
  9.     scanf("%d%d", &a, &b);  
  10.   
  11.     if(a > b)  
  12.     {  
  13.         big = a;  
  14.     }  
  15.     else  
  16.     {  
  17.        big = b;  
  18.     }  
  19.   
  20.     printf("Biggest of %d and %d is %d\n", a, b, big);  
  21.   
  22.     return 0;  
  23. }  

Output:
Enter 2 numbers
75
100
Biggest of 75 and 100 is 100

For list of all c programming interviews / viva question and answers visit: C Programming Interview / Viva Q&A List

For full C programming language free video tutorial list visit:C Programming: Beginner To Advance To Expert

One thought on “Biggest of Two Numbers: C”

Leave a Reply

Your email address will not be published. Required fields are marked *