Wednesday, 25 May 2011

if-else Statement

It is a conditional expression and easy to use.


#include<stdio.h> 
#include<conio.h>
void main()
{
 char ch;
 clrscr();
 ch=getche();
 if(ch=='y')
 printf("\nYou typed y");
 else
 printf("\nYou didn't type y");
 getch();
}


In the above code when you type 'y', the output will be "You typed y" other it will print "You didn't type y".


If you have any question, you can ask me freely!

1 comments:

Manish Kumar said...

Good example for c if-else ladder.

Thanks,
Merient Infotech

Post a Comment