asked 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

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;

}

answered
User SSemashko
by
8.2k points

No related questions found