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:-
- Very Cool numbers | Hacker earth solution
- Vowel Recognition | Hackerearth practice problem solution
- Birthday party | Hacker earth solution
- Most frequent | hacker earth problem solution
- program to find symetric difference of two sets
- cost of balloons | Hacker earth problem solution
- Chacha o chacha | hacker earth problem solution
- jadu and dna | hacker earth solution
- Bricks game | hacker earth problem
- Anti-Palindrome strings | hacker earth solution
- connected components in the graph | hacker earth data structure
- odd one out || hacker earth problem solution
- Minimum addition | Hackerearth Practice problem
- The magical mountain | Hackerearth Practice problem
- The first overtake | Hackerearth Practice problem
Data structure:-
- Program to find cycle in the graph
- Implementation of singly link list
- Implementation of queue by using link list
- Algorithm of quick sort
- stack by using link list
- program to find preorder post order and inorder of the binary search tree
- Minimum weight of spanning tree
- Preorder, inorder and post order traversal of the tree
Key points:-
- How to set limit in the floating value in python
- What is boolean data type
- How to print any character without using format specifier
MCQs:-
0 Comments