Demonstration of If else - condition

, by Prashant Gunjal




syntax : if(condition)
{
.
.
.
body of if part
.
.
.
}
else
{
.
.
.
body of else part
.
.
.
}

Program : Here we will print status of login (Assume :- password is 111)

#include<stdio.h>
void main()
{
int no;
clrscr();
printf("\n\tEnter password : "); //Ask user to enter number
scanf("%d",&no);              // accept number
if(no==111)                  // check whether number less than 10 or not
{
printf("\n\t**Successfull loged in ***"); //display message
}
else
{
printf("\n*** Please enter correct password ***");
}
getch(); //hold screen until user press any key
}

OUTPUT :


0 comments: