5. Example:
#include <stdio.h>
int main()
{
int x = 20;
int y = 22;
if (x<y) {
printf("Variable x is less than y");
}
if (x>y) {
printf("Variable x is greater than y");
}
}
//try this x and y value input
7. Example:
#include <stdio.h>
int main() {
int number;
printf("Enter an integer: ");
scanf("%d",&number); // True (if remainder is 0)
if (number % 2 == 0)
printf("%d is an even integer.",number);
else
printf("%d is an odd integer.",number);
return 0;
}
10. Example:
#include <stdio.h>
int main()
{
int x = 20;
int y = 22;
int z = 23;
if (x>y&&x>z)
{printf("Variable x=%d is greater than all value",x);}
else if (y>z&&y>x)
{printf("Variable y=%d is greater than all value",y);}
else
{printf("Variable z=%d is greater than all value",z);}
}
11. Example:
#include <stdio.h>
int main()
{
char ch ;
scanf("%c",&ch);
if (ch == 'A’ || ch=='E'||ch=='I'||ch=='O'||ch=='U')
{printf("%c is capital leter VOWEL",ch);}
else if (ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
{printf("%c small leter VOWEL",ch);}
else
{printf("%c is not vowel",ch);}
}
12. switch statement:
Syntax:
switch (n)
{ case constant1:
// executed if n is equal to constant1;
break;
case constant2:
// executed if n is equal to constant2;
break; . . .
default:
executed if n doesn't match any constant }