If Statement:-
Compare Number Use if statement first of all Header file include <stdio.h> then star main function In this program uses six if statement compare two numbers entered by the user.if the condition in any of these if statement is true,the printf statement associated with that if executes.The program and three sample execution outputCODE:-
#include<stdio.h>
int main()
{
int num1;//first number to be read from user
int num2;//second number to be read fromn user
printf("Enter two integers,and i will tell you\n");
printf("the relationships they satisfy: ");
scanf("%d%d",&num1,&num2);//read two integers
if( num1==num2)
{
printf("%d is equal to %d\n",num1,num2);
}//end if
if( num1!=num2)
{
printf("%d is not eual to %d\n",num1,num2);
}//end if
if(num1<num2)
{
printf("%d is less than %d\n",num1,num2);
}//end if
if(num1>num2)
{
printf("%d is greater than %d\n",num1,num2);
}
if(num1<=num2)
{
printf("%d is less than or equal to %d\n",num1,num2);
}//end if
if(num1>=num2)
{
printf("%d is greater than or equal to %d\n",num1,num2);
}//end if
} //end function main
OUTPUT:-
Enter two integers,and i will tell you
the relationships they satisfy: 12 33
12 is not eual to 33
12 is less than 33
12 is less than or equal to 33
No comments:
Post a Comment
Thanks for comment