switch case questions in c code example
Example 1: switch statement in c
#include <stdio.h>
int main(void)
{
int a = 0;
switch(a)
{
case 1 :
statement("a = 1");
break;
case 2 :
printf("a = 2");
break;
default :
printf("a is neither 1 or 2");
break;
}
}
Example 2: “switch case c” Code Answer
include <stdio.h>
int main() {
int n;
printf(" enter number between 1 to 3");
scanf("%d", &n);
switch (n) {
case 1:
printf("\n one");
break;
case 2:
printf("\n two");
break;
case 3:
printf("\n three");
break;
default:
printf("\n wrong number");
}
return 0;
}