When should a switch statement be used?

1 answer

Answer

1148901

2026-05-13 15:50

+ Follow

switch is a loop which is used for checking various conditions and print corresponding matter.

switch(a)//where a is that whose condition you have to check.

#include

main()

{

char a;

printf("enter a char.");

scanf("%c",&a);

switch(a)

{

case 'a':printf("vowel");break;

case 'e':printf("vowel");break;

case 'i':printf("vowel");break;

case 'o':printf("vowel");break;

case 'u':printf("vowel");break;

default:printf("consonent");

}

}

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.