Switch (Expression){ case Constant 1 : Statement Sequence 1;break; case Constant 2 : Statement Sequence 2;break; case Constant 3 : Statement Sequence 3;break; ........ ........ case ConstantN-1 : Statement SequenceN-1;break; deafault : StatementSequenceN; }
#include<stdio.h> main(){ int n; printf("enter your choice:"); scanf("%d",&n); switch(n){ case 1: printf("you are selected first case");break; case 2: printf("you are selected second case");break; case 3: printf("you are selected third case");break; case 4: printf("you are selected fourth case");break; case 5: printf("you are selected fifth case");break; case 6: printf("you are selected sixth case");break; case 7: printf("you are selected seventh case");break; default:printf("invalid input"); } }
enter your choice:3 you are selected third case