Switch statement switch statement is an extension of if...else statement. This permits any number of branches. The general form is switch(expression) { case 1 statement block-1; break; case 2 statement block-2; break; .............. .............. .............. case n statement block-n; break; default default statement; break; } next statement; the value of the expression will check with the case 1, case2,...casen if any case will matches then execute that case statement.then it moves to the next statement. flow diagram: Example program: #include<stdio.h> #include<conio.h> void main() { int number; clrscr(); printf("Enter your exam mark"); scanf("%d",&number); switch(number) { case 35: printf("low mark"); break; case 50: printf("better mark"); break; case 90: printf(...
Comments
Post a Comment