Home »
C solved programs »
C switch case programs
C program to check whether a character is VOWEL or CONSONANT using switch
This program will read a character from user and check whether it is VOWEL or CONSONANT if entered character was an alphabet using switch case statement in c programming language.
Check VOWEL or CONSONANT program using switch
/*C program to check whether a character is
VOWEL or CONSONANT using switch.*/
#include <stdio.h>
int main() {
char ch;
printf("Enter a character: ");
scanf("%c", & ch);
//condition to check character is alphabet or not
if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) {
//check for VOWEL or CONSONANT
switch (ch) {
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
printf("%c is a VOWEL.\n", ch);
break;
default:
printf("%c is a CONSONANT.\n", ch);
}
} else {
printf("%c is not an alphabet.\n", ch);
}
return 0;
}
Output
First Run:
Enter a character: E
E is a VOWEL.
Second Run:
Enter a character: X
X is a CONSONANT.
Third Run:
Enter a character: +
+ is not an alphabet.
C Switch Case Programs »
Other C language basic programs
- C program to print "Hello World!" / First C program.
This is our first program in C language; this program will print “Hello World” on the screen, it is implemented using simple method as well as using c language user defined function.
- Program to find sum and average of two numbers.
In this program, we will read two integer numbers and find their SUM and Average and then both results will be printed on the screen.
- C program to find cube of an integer number using two different methods.
In this C program, we are going to find cube of an integer number. Here, we will implement the program by using two methods 1) without using pow() function and 2) using pow() function.
- C program to find quotient and remainder.
In this program, we will read divisor and dividend and then find the quotient and remainder, results will be printed on the screen.
- Program to calculate simple interest.
In this program we will read principle, amount and rate and then calculate simple interest of borrowed principle based on give number of years and rate.
- Program to check whether number is EVEN or ODD.
In this C program, we will read an integer number and program will check whether given integer number is EVEN or ODD.
- Program to find largest number among three numbers.
In this C program, we will read three integer number from user and print the largest number among them.
- C program to check whether a person is eligible for voting or not?
In this program, we are going to learn how to check that, a person is eligible for voting or not, when age is given or input through the user?
- C program to read marks and print percentage and division.
In this C program, we are going to read marks in 3 subjects, we will find the total, percentage and print the division based on the percentage.
- Program to find gross salary of an employee.
In this program, we will read Basic Salary of an employee and calculate HRA, DA, and Provident Fund, based on these parameters we will calculate the gross salary of the employee and print it on the screen.
- C program to convert temperature from Fahrenheit to Celsius and vice versa.
This C program is to convert temperature from Fahrenheit to Celsius and vice versa, program will ask the choice for conversion from the user and find the converted temperature based on given input.
- C program to calculate X^N (X to the power of N) using pow function.
This C program will read two integer number as X and Y and them calculate the X^Y (X to the power Y) and print the result on Screen.
- C program to find the difference of two numbers.
This C program cannot be used to find the subtraction, in this program we are going to find the differences of two integer numbers. Here, we will check which largest number is and to get the difference, smallest number will be subtracted from largest number.
- C program to print size of variables using sizeof() operator.
sizeof() is an operator in C language, which is used to print the occupied size of a variable (or size of a value), in this C program, we will print the size of different declared variables.
- C program to demonstrate examples of escape sequences.
Escape sequences are the set of characters followed by the escape (\), in this program, we will learn to use of different escape sequence like new line character, backspace character etc.
- C program to find area and perimeter of circle.
This c program will read radios of a circle and find their perimeter and area of a circle.
- C program to find area of a rectangle.
This c program will read length and breadth of a rectangle and calculate its area; area of rectangle will be printed on the screen.
- C program to calculate HCF of two numbers.
This program will read two integers and print their HCF (Highest Common Factor).
- C program to multiply two numbers using plus operator.
This C program will read two integer numbers and calculate their multiplication (product) using plus operator, here we will not multiplication (*) operator.
- C program to demonstrate example of global and local scope.
Basically, variables have two types of scopes, in which they can be accesses. This C program, we will demonstrate use of Global and Local scope of variables.
- C program to demonstrate example of floor and ceil functions.
This C program will find the rounded float values using floor and ceil function, which are the library functions of math.h header file.
- C program to read Formatted Time Once through Scanf in C Language.
In this C program we will learn how to read formatted time using scanf(), the input formatted will be “HH:MM:SS”.
- C program to define, modify and access a global variable.
In this C program, we will learn how to declare, define, access and modify the value of Global variables in C programming language?
- C program to convert feet to inches.
This C program will read distance in feet and convert the distance in inches. Then program will print converted feet and remaining inches on the screen.
- C program to print value in Decimal, Octal, Hexadecimal using printf.
This C program will read an integer value using decimal format and print the values in Octal, Decimal and Hexadecimal format using printf.
- C program to print ASCII value of entered character.
This C program will read a character from user and print its ASCII code (value) on the screen.
- C program to print How Many Inputs are taken from Keyboard using Scanf?
Here, you will learn how to count total number of inputs using scanf(), suppose you read three different values using scanf(), it will return 3.
- C Program to calculate Employee and Employer Provident Fund.
In this C program, we will read BASIC salary of an employee and calculate employee and employer (company) provident fund contribution.
- C program to set buffer with specific value using memset in C - Example of memset().
This C program will demonstrate example of memset(), learn how to set specific value to a buffer (character arrays) using memset()?
- Write a C program to evaluate the net salary of an employee given the following constraints.
Given Basic Salary, DA, HRA, TA and Other we have to calculate Net Salary of an employee where tax dedication of PF and IT using C program.
- How to swap two numbers without using a temporary variable using C program?
C program to swap two integer numbers without using temporary variable: Here, we will learn how to swap numbers without taking help of another variable in C?