22. WRITE A C PROGRAM TO EXPLAIN SWITCH PROGRAM, WITHOUT USING BREAK(READ AN INTEGER VALUE BETWEEN 1 TO 5 AND PRINT IT IN WORDS)
/*program to print an integer value in words*/
#include<stdio.h>#include<conio.h>
int main()
{
int a;
clrscr();
printf(“enter a value\n”);
scanf(“%d”,&a);
switch(a)
{
case 1: printf(“the number is one”);
case 2: printf(“the number is two”);
case 3: printf(“the number is three”);
case 4: printf(“the number is four”);
case 5: printf(“the number is five”);
default :(“the number is invalid”);
}
getch();
return 0;
}
output
enter a value 4the number is four the number is five the number is invalid
Comments
Post a Comment