The general form of a simple if...else statement is,
if(expression)
{
statement-block1;
}
else
{
statement-block2;
}
If the 'expression' is true, the 'statement-block1' is executed, else 'statement-block2' is executed.
//Write a C Program which demonstrate use of if else-statement.
#include<stdio.h>
#include<conio.h>
void main()
{
int x,y;
x = 5;
y = 7;
if (x > y)
{
printf("x is greater than y");
}
else
{
printf("y is greater than x");
}
getch();
}
Ask Question