if-else statement is a conditional statement which allows us to select and execute one statement or a group of statement out of two available statements or group of statements depending upon the truthfulness of a condition.
ads
Syntax-:
if(condition)
statement-1;
else
statement-2;
or,
if(condition);
{ statement-1;
statement-2;
statement-3;
-
-
-
statement-n;
}
else
{statement-1;
-
-
-
statement-n;
}
Example-:#include<stdio.h>
#include<conio.h>
main()
{int num=0;
printf("Enter the value of num");
scanf("%d",&num);
if(num%2==0)
printf("\n Even number");
else
printf("\n odd number);
getch();
}
output-:Enter the value of num 15
odd number
please follow and share techprogramiz blogs
ReplyDelete