Example Of if else statement in C programming.
flowchart:-
#include<stdio.h>
#include<conio.h> //include header files
void main()
{
int n;
printf("\n enter a number:-");
scanf("%d",&n); //accept number from user
if(n>100)
{
printf("\n number is greater than 100"); //if the condition is true this msg will display
}
else
{
printf(" number is less than 100"); //if the condition is false then this msg will display
}
}
Output:-
enter a number : 50
number is less than 100
Explanation:-
- Here program accepts a number from user.
- If the number is greater than 100, it will print the massage--"Number is greater than 100".
-If number is less than 100, it will print the massage "number is less than 100"
flowchart:-
Program
#include<stdio.h>
#include<conio.h> //include header files
void main()
{
int n;
printf("\n enter a number:-");
scanf("%d",&n); //accept number from user
if(n>100)
{
printf("\n number is greater than 100"); //if the condition is true this msg will display
}
else
{
printf(" number is less than 100"); //if the condition is false then this msg will display
}
}
Output:-
enter a number : 50
number is less than 100
Explanation:-
- Here program accepts a number from user.
- If the number is greater than 100, it will print the massage--"Number is greater than 100".
-If number is less than 100, it will print the massage "number is less than 100"
No comments:
Post a Comment