Header Ads Widget

Ticker

6/recent/ticker-posts

Practice questions (Programs ) based on switch-case

 Here I am giving some question based on the switch statement . So solve these objectives carefully for better understanding of switch statement. These programs helps you to understand and clear all the doubts related to the switch statement.

C Program based on switch case:-

1.Using switch statement Write a C program to input marks of five subjects Physics, Chemistry, Biology, Mathematics and Computer. Calculate percentage and grade according to following:

Percentage >= 90% : Grade A

Percentage >= 80% : Grade B

Percentage >= 70% : Grade C

Percentage >= 60% : Grade D

Percentage >= 40% : Grade E

Percentage < 40% : Grade F

2.C  Program to find the maximum between two numbers. Using the switch statement

3. C  Program to find the maximum between three numbers. Using the switch statement.

 4.C  Program to check whether a number is divisible by 5 and 11 or not. Using the switch statement.

 5.C  Program to check whether a year is a leap year or not. Using switch statement

 6.C  Program to check whether a character is an alphabet or not. Using the switch statement. 

7.C  Program to take the value from the user as input any alphabet and check whether it is vowel or consonant. Using the switch statement. 

 8.C  Program to take the value from the user as input any character and check whether it is the alphabet, digit or special character. Using the switch statement

9. C  Program to check whether a character is an uppercase or lowercase alphabet. Using the switch statement. 

 10.C  Program to take the value from the user as an input week number and print weekday by using the switch statement. 

 11.C  Program to take the value from the user as input the month number and print number of days in that month. Using switch statement 

12. C  Program to count the total number of notes in a given amount. Using the switch statement. 

13.C  Program to take the value from the user as input all sides of a triangle and check whether the triangle is valid or not. Using switch statement 

14. C  Program to check whether the triangle is an equilateral, isosceles or scalene triangle. Using switch statement

 15.C  Program to find all the roots of a quadratic equation. Using switch statement

 16.C  Program to calculate profit or loss. Using switch statement.

17. C  Program to take the value from the user as input marks of five subjects Physics, Chemistry, Biology, Mathematics, and Computer. Calculate percentage and grade according to the following: Percentage >= 90% : Grade A, 

Percentage >= 80% : Grade B, 

Percentage >= 70% : Grade C, 

Percentage >= 60% : Grade D,

Percentage >= 40% : Grade E, 

Percentage < 40% : Grade F, 

Using switch statement.

 18.C  Program to take the value from the user as input the basic salary of an employee and calculate its Gross salary according to the following: 

Basic Salary <= 10000: HRA = 20%, DA = 80%………………………………..

Basic Salary <= 20000 : HRA = 25%, DA = 90%………………………………

Basic Salary > 20000 : HRA = 30%, DA = 95%.

19.C  Program to take the value from the user as input electricity unit charges and calculate total electricity bill according to the given condition: 

For the first 50 units Rs. 0.50/unit………….

For the next 100 units Rs. 0.75/unit…..

For the next 100 units Rs. 1.20/unit ……………

For unit above 250 Rs. 1.50/unit………

An additional surcharge of 20% is added to the bill…….

Using the switch statement. 

20. Write a program that determines a student’s grade. The program will read three types of scores (quiz, mid-term, and final scores) and determine the grade based on the following rules:

if the average score =90% =>grade=A…………………..-

if the average score >= 70% and <90% => grade=B……………………-

if the average score>=50% and <70% =>grade=C……………………..-

if the average score<50% =>grade=F

21.Program to take the hours and minutes as input by the user and the show that whether it is AM or PM by using the switch statement. 

22.Program to convert a positive number into negative number and negative number into a positive number using switch  statement 


<<Pre - Switch Case in C Next - Loops in C part-1>>




Recommended Post:

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

Key points:-

 MCQs:-


Post a Comment

0 Comments