Syntax-
if(condition)
{
}
else
{
}
-If the condition is true then if part is execute otherwise else part is execute.
Example-
if(2==8)
{
printf("If part");
}
else
{
printf("Else part");
}
//Else part
program-
#include< stdio.h>
int main()
{
int a;
printf("Enter Number\n");
scanf("%d",&a);
if(a==1)
{
printf("If part");
}
else
{
printf("Else part");
}
}
Enter Number
5
Else part
Enter Number
1
If part