16.0k views
2 votes
Write a program to read 2 numbers and display the largest of the two. You should use scanfto read the two numbers and use if statement to see which number is larger

User Arvymetal
by
4.7k points

1 Answer

3 votes

Answer: in C

#include <stdio.h>

int main(){

int num1, num2;

printf("Enter first number :: ");

scanf("%d", &num1);

printf("Enter second number :: ");

scanf("%d", &num2);

if(num1 > num2){

printf("%d is larger than %d\\", num1, num2);

} else if (num2 > num1) {

printf("%d is larger than %d\\", num2, num1);

} else{

printf("Both of them are equal\\");

}

return 0;

}

User SSemashko
by
5.6k points