if Statements with Compound Statements :
When multiple statements must be executed as a result of a single condition, a
compound statement is used. A compound statement consists of a group of
statements enclosed within braces {} and is treated as a single unit by the
if statement.
Compound statements allow the programmer to execute several actions whenever a
condition evaluates to true, thereby improving program clarity and logical
organization.
When multiple statements must be executed as a result of a single condition, a
compound statement is used. A compound statement consists of a group of
statements enclosed within braces {} and is treated as a single unit by the
if statement.
Compound statements allow the programmer to execute several actions whenever a
condition evaluates to true, thereby improving program clarity and logical
organization.
EXAMPLE:
#include<stdio.h>
int a=300;
int main(){
if(a>=100){
printf("Hi\n");
printf("a is greater than or equal to 100",a);
}
return 0;
}
Output:
Hi
a is greater than or equal to 100