Syntax/s:
if (condition) statement;
if (condition)
{
statement
statement
}
if (condition is true) execute this; else execute this instead;
> GREATER THAN
< LESS THAN
>= GREATER THAN OR EQUAL TO
<= LESS THAN OR EQUAL TO
== EQUAL TO
CASE SWITCH
SYNATX/S:
switch (variable){ case constant expression: statement;breal;default:statement;
}
EXAMPLE:
#include
char choice;
void main() {
clrscr();
printf("What color do you like?");
printf("\n\ta) red");
printf("\n\tb) blue");
printf("\n\tc) Purple");
printf("\n\td) Yellow ");
choice=getch();
switch (choice) {
case 'a': printf("\nI like red "); break;
case 'b': printf("\nI like blue "); break;
case 'c': printf("\nI like Purple"); break;
case 'd': printf("\nI like Yellow"); break;
default: printf("Yes");
}
getch();

No comments:
Post a Comment