Demonstration of If - condition
syntax : if(condition)
{
.
.
.
body
.
.
.
}
at the place of condition we can compare two numbers or check certain condition
ex. to check number is less than 10 or not we can write if as
if ( number<10 )
in body we can write multiple c statements that will execute after satisfying condition
Program :
#include<stdio.h>
void main()
{
int no;
clrscr();
printf("\n\tEnter number : "); //Ask user to enter number
scanf("%d",&no); // accept number
if(no<10) // check whether number less than 10 or not
{
printf("\n\t**Number is less than 10 ***"); //display message
}
getch(); //hold screen until user press any key
}
OUTPUT :
0 comments:
Post a Comment