Some use case :
1.
if(condition)
{
//block of statement
if(condition)
{
//block of statement
}
}
2.
if(condition)
{
//black of statement
}
else
{
if(condition)
{
//block of statement
}
else
{
//block of statement
}
}
3.
if(condition)
{
//black of statement
}
else if(condition)
{
if(condition)
{
//block of statement
}
else
{
//block of statement
}
}
Example :
#include <stdio.h>
int main()
{
int numb1, numb2;
printf("Enter two integers : ");
scanf("%d %d",&numb1,&numb2);
//checking whether two integers are equal.
if(numb1==numb2)
{
printf("\nResult: %d = %d",numb1,numb2);
}
else
{
//checking whether numb1 is greater than numb2.
if(numb1>numb2)
{
printf("\nResult: %d > %d",numb1,numb2);
}
else
{
printf("\nResult: %d > %d",numb2,numb1);
}
}
return 0;
}
Output :
Enter two integers : 7 9 Result: 9 > 7
No comments:
Post a Comment