Syntax of Simple-if
-------------------------
Simple C Program to understand Simple if :
-------------------------
if(condition)
{
statement1;
statement2;
.
.
.
statement n;
}
Simple C Program to understand Simple if :
#include<stdio.h>
void main()
{
int age;
printf(" >>> c program to implement simple if<<< \n\n");
printf("\n Enter the age of the person: ");
scanf("%d",&age);
if(age>=18)
{
printf("\n Eligible for voting \n");
}
printf("\n program ends \n\n");
}
Output:
Explanation:
In the above program, the control enters into the if block only if the condition is true. And the statement printf("\n program ends \n\n"); is executed every time.
No comments:
Post a Comment
Thanks for your comments.
-Sameer