Search This Blog

Showing posts with label Switch Case C Programs. Show all posts
Showing posts with label Switch Case C Programs. Show all posts

C Program Find Vowel Consonant Space In Given Word Using SwitchCase

C Program Find Vowel Consonant Space In Given Word Using SwitchCase :
//C Program Find Vowel Consonant Space In Given Word Using SwitchCase

#include<stdio.h>
#include<conio.h>
void main()
{
char word[50];
int i=0,c=0,v=0,s=0;
clrscr();
puts("\n\n Enter any word: ");
gets(word);
while(i<50 && word[i]!=NULL)
{
switch(word[i])
{
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
printf("\n %c is a vowel",word[i]);
v++;
break;
default:
{
if(word[i]==' ')
{printf("\n \t space");s++;
break;}
else
{
printf("\n %c is a constant",word[i]);
c++;
break;
}}}
i++;
}
printf("\n\n Total vowels is: %d", v);
printf("\n Total consonant is: %d", c);
printf("\n Total space is: %d",s);
getch();
}
OUTPUT
C Program Find Vowel Consonant Space In Given Word

C Program Check Given Alphabet Is Vowel Or Not Using SwitchCase

C Program Check Given Alphabet Is Vowel Or Not Using SwitchCase :
//C Program Check Given Alphabet Is Vowel Or Not Using SwitchCase

#include<stdio.h>
#include<conio.h>
void main()
{
char ch;
clrscr();
printf("\n\n Enter any one character:-");
ch=getche();
switch(ch)
{
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
printf("\n The alphabate is vowel");
break;
default:
printf("\n The alphabate is constant");
break;
}
getch();
}
OUTPUT
C Program Check Given Alphabet Is Vowel Or Not Using SwitchCase

C Program Perform Arithmetic Operations Using SwitchCase

C Program Perform Arithmetic Operations Using Switch Case :
//C Program Perform Arithmetic Operations Using SwitchCase

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
int ch;
float a,b,res;
clrscr();
printf("\n Enter I numbers:- ");
scanf("%f",&a);
printf("\n Enter II numbers:- ");
scanf("%f",&b);
printf("\n Menu\n 1.Addition\n 2.Subtraction\n 3.Multiplication\n 4.Division\n");
printf("\n Enter your choice:- ");
scanf("%d",&ch);
switch(ch)
{
case 1: res=a+b;
break;
case 2: res=a-b;
break;
case 3: res=a*b;
break;
case 4: res=a/b;
break;
default: printf("\n Wrong choice!!nPress any key… ");
getch();
exit(0);
}
printf("\n Result= %f",res);
getch();
}
OUTPUT
C Program Perform Arithmetic Operations Using SwitchCase

C Program Display Day Name According To The Day Number

C Program Display Day Name According To The Day Number :
//C Program Display Day Name According To The Day Number

#include<stdio.h>
#include<conio.h>
void main()
{
int dnum;
clrscr();
printf("\n Enter number of week day(1-7):- ");
scanf("%d",&dnum);
switch(dnum)
{
case 1: printf("\n Sunday");
break;
case 2: printf("\n Monday");
break;
case 3: printf("\n Tuesday");
break;
case 4: printf("\n Wednesday");
break;
case 5: printf("\n Thursday");
break;
case 6: printf("\n Friday");
break;
case 7: printf("\n Saturday");
break;
}
getch();
}
OUTPUT
C Program Display Name Of Day In Week