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
#include < stdio.h > int main() { int a, b; printf("Enter 2 numbers\n"); scanf("%d%d", &a, &b); if(a > b) { printf("Biggest of %d and %d is %d\n", a, b, a); } else { printf("Biggest of %d and %d is %d\n", a, b, b); } return 0; }
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 https://www.youtube.com/watch?v=Bx_aowugT3E]
C Program To Find Biggest of 2 numbers
#include < stdio.h > int main() { int a, b, big; printf("Enter 2 numbers\n"); scanf("%d%d", &a, &b); if(a > b) { big = a; } else { big = b; } printf("Biggest of %d and %d is %d\n", a, b, big); return 0; }
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