Showing posts with label Switch Case. Show all posts
Showing posts with label Switch Case. Show all posts
,

C Program to Check Whether a Character is a Vowel or Consonant

C Program to Check Whether a Character is a Vowel or Consonant

C Program to Check Whether a Character is a Vowel or Consonant


In this program, I have discussed about the C program to check whether a character is a vowel or consonant.

#include<stdio.h>
int main()
{ char a;

printf("Enter an alphabet:");
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;
case 'A': printf("Vowel");
break;
case 'E': printf("Vowel");
break;
case 'O': printf("Vowel");
break;
case 'I': printf("Vowel");
break;
case 'U': printf("Vowel");
break;
default: printf("Consonant");
}
}

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.

,

C program to perform addition, subtraction, multiplication and division using switch case

C program to perform addition, subtraction, multiplication and division using switch case


C program to perform addition, subtraction, multiplication and division using switch case


 In this program, I have discussed about the  program to perform addition, subtraction, multiplication and division using switch case

-----------------------------------------------------------------------------------

#include<stdio.h>
void main()
{
 char ch;
 int a,b,r;
 printf("Enter + or - or * or /");
scanf("%c",&ch);
printf("Enter two numbers");
scanf("%d%d",&a,&b);
switch (ch)
{
case '+':
r=a+b;
break;
case '-':
r=a-b;
break;
case '*':
r=a*b;
break;
case '/':
r=a/b;
break;
default:
printf("Invalid Input");
}
printf("Result= %d",r);
}


-------------------------------------------------------------------------------


Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.

 

Copyright 2020 Programming in C All Right Reserved