//1. Chceck input number is 1,2 or 3
#include<stdio.h>
int main()
{
int n;
printf("Enter a Number:");
scanf("%d",&n);
switch( n )
{
case 1 : printf( "Your number is 1\n" );
break;
case 2 : printf( "Your number is 2\n" );
break;
case 3 : printf( "Your number is 3\n" );
break;
default : printf( "Try Again\n" );
break;
}
return 0;
}
==============================================================
===============================================================
//2.Check user input letter is vowel or not
#include<stdio.h>
int main()
{
char ch;
printf("Enter the Vowel (In Capital Letter):");
scanf("%c",&ch);
switch( ch )
{
case 'A' : printf( "Your Character Is A\n" );
break;
case 'E' : printf( "Your Character Is E\n" );
break;
case 'I' : printf( "Your Character Is I\n" );
break;
case 'O' : printf( "Your Character Is O\n" );
break;
case 'U' : printf( "Your Character Is U\n" );
break;
default : printf( "Your Character is Not Vowel.Otherwise Not a Capital Letter\n" );
break;
}
return 0;
}
===============================================================
//3.check week name
#include<stdio.h>
int main()
{
int day;
printf("Enter a number:");
scanf("%d",&day);
switch (day)
{
case 1 : printf("Sunday\n");
break;
case 2 : printf("Monday\n");
break;
case 3 : printf("Tuesday\n");
break;
case 4 : printf("Wednesday\n");
break;
case 5 : printf("Thursday\n");
break;
case 6 : printf("Friday\n");
break;
case 7 : printf("Saturday\n");
break;
default : cout << "Not an allowable day number";
break;
}
return 0;
}
===============================================================
//check color
#include <stdio.h>
int main() {
int color = 1;
printf("Please choose a color(1: red,2: green,3: blue):\n");
scanf("%d", &color);
switch (color) {
case 1:
printf("you chose red color\n");
break;
case 2:
printf("you chose green color\n");
break;
case 3:
printf("you chose blue color\n");
break;
default:
printf("you did not choose any color\n");
}
return 0;
}
=============================================================
//5.check student grade
#include <stdio.h>
main()
{
int Grade = 'B';
switch( Grade )
{
case 'A' : printf( "Excellent\n" );
break;
case 'B' : printf( "Good\n" );
break;
case 'C' : printf( "OK\n" );
break;
case 'D' : printf( "Mmmmm....\n" );
break;
case 'F' : printf( "You must do better than this\n" );
break;
default : printf( "What is your grade anyway?\n" );
break;
}
}
=============================================================
#include<stdio.h>
int main()
{
int n;
printf("Enter a Number:");
scanf("%d",&n);
switch( n )
{
case 1 : printf( "Your number is 1\n" );
break;
case 2 : printf( "Your number is 2\n" );
break;
case 3 : printf( "Your number is 3\n" );
break;
default : printf( "Try Again\n" );
break;
}
return 0;
}
==============================================================
===============================================================
//2.Check user input letter is vowel or not
#include<stdio.h>
int main()
{
char ch;
printf("Enter the Vowel (In Capital Letter):");
scanf("%c",&ch);
switch( ch )
{
case 'A' : printf( "Your Character Is A\n" );
break;
case 'E' : printf( "Your Character Is E\n" );
break;
case 'I' : printf( "Your Character Is I\n" );
break;
case 'O' : printf( "Your Character Is O\n" );
break;
case 'U' : printf( "Your Character Is U\n" );
break;
default : printf( "Your Character is Not Vowel.Otherwise Not a Capital Letter\n" );
break;
}
return 0;
}
===============================================================
//3.check week name
#include<stdio.h>
int main()
{
int day;
printf("Enter a number:");
scanf("%d",&day);
switch (day)
{
case 1 : printf("Sunday\n");
break;
case 2 : printf("Monday\n");
break;
case 3 : printf("Tuesday\n");
break;
case 4 : printf("Wednesday\n");
break;
case 5 : printf("Thursday\n");
break;
case 6 : printf("Friday\n");
break;
case 7 : printf("Saturday\n");
break;
default : cout << "Not an allowable day number";
break;
}
return 0;
}
===============================================================
//check color
#include <stdio.h>
int main() {
int color = 1;
printf("Please choose a color(1: red,2: green,3: blue):\n");
scanf("%d", &color);
switch (color) {
case 1:
printf("you chose red color\n");
break;
case 2:
printf("you chose green color\n");
break;
case 3:
printf("you chose blue color\n");
break;
default:
printf("you did not choose any color\n");
}
return 0;
}
=============================================================
//5.check student grade
#include <stdio.h>
main()
{
int Grade = 'B';
switch( Grade )
{
case 'A' : printf( "Excellent\n" );
break;
case 'B' : printf( "Good\n" );
break;
case 'C' : printf( "OK\n" );
break;
case 'D' : printf( "Mmmmm....\n" );
break;
case 'F' : printf( "You must do better than this\n" );
break;
default : printf( "What is your grade anyway?\n" );
break;
}
}
=============================================================