Switch case programming exercises and solutions in C++

Let us see a list of important Switch case programming exercises and solutions in C++.

  1. Simple Calculator: Add, Subtract, Multiply, Divide
  2. hours and minutes as input and show that whether it is AM or PM 
  3. 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
  4. convert a positive number into negative number and negative number into a positive number 
  5. swap the values of two numbers if the values of both variables are not the same
  6. Convert even number into its upper nearest odd number
  7. 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. 
  8. check Vowel
  9.  take the value from the user as an input week number and print weekday
  10. take the value from the user as input the month number and print number of days in that month
  11.  count the total number of notes in a given amount.
  12.  take the value from the user as input all sides of a triangle and check whether the triangle is valid or not
  13.  maximum between two numbers
  14.  calculate profit or loss.
  15. Day of the Week: Print Day Name
  16. Vowel or Consonant Check
  17. Even or Odd Check
  18. Grade Calculation Based on Marks
  19. Month Name from Number
  20. Season from Month Number
  21. character is an alphabet or not
  22. character is an uppercase or lowercase alphabet
  23. Area Calculation: Circle, Square, Rectangle
  24. Convert Number to Words (1-9)
  25. Traffic Light Simulation: Red, Yellow, Green
  26. Number of Days in a Month
  27. Unit Conversion: Length (Meters to Kilometers, Centimeters, etc.)
  28. Week Number to Day of the Week
  29. Grade Point to Letter Grade Conversion
  30. Electricity Bill Calculation Based on Units Consumed
  31. Simple Interest Calculation
  32. Check Whether a Character is Uppercase or Lowercase
  33. Identify Type of Angle: Acute, Right, Obtuse
  34. Print a Simple Menu

If else with Switch

  1. if else with switch – Triangle Type Check: Equilateral, Isosceles, Scalene
  2. if else with switch – Leap Year Check

Basic Tutorial of conditional statements

shamil memory table

Add a Comment