LearnFrenzy
Sign in Take a free test

Control Instructions · Exercise 4 of 4

Control Instructions Decision Making Programs

  • 8 questions
  • Page 1 of 1
  • Answers explained
0Attempted
0Correct
0Wrong
Directions

Programs built on if-else and switch – classic placement-test questions. Write each one yourself first, then open the solution; every solution was compiled and run, and the output shown is the real output.

Question 1 Easy

Write max3() that returns the largest of three integers, correct for negative and equal values.

Question page & discussion
Question 2 Medium

Solve ax² + bx + c = 0 and report two real roots, one repeated root, or complex roots, depending on the discriminant.

Question page & discussion
Question 3 Medium

Compute a bill: the first 100 units at Rs. 3.00, the next 100 at Rs. 4.50, the next 100 at Rs. 6.00, everything above 300 at Rs. 7.50, plus a fixed charge of Rs. 50.

Question page & discussion
Question 4 Easy

Print the day name for 1–7 (1 = Monday), mark weekends, and reject invalid numbers.

Question page & discussion
Question 5 Easy

Classify each character as a vowel, consonant, digit, space or special character.

Question page & discussion
Question 6 Medium

Decide the winner of rock-paper-scissors for any two moves without listing all nine combinations.

Question page & discussion
Question 7 Medium

Check whether a day/month/year combination is a real calendar date, including leap years.

Question page & discussion
Question 8 Medium

Write a menu-driven ATM: 1 = balance, 2 = deposit, 3 = withdraw, 4 = exit. Refuse invalid choices and withdrawals larger than the balance.

Input: 1, 2 500, 3 200, 3 5000, 9, 4

Question page & discussion
All exercises doneBack to Control InstructionsRevise the concepts or pick another topic

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Search LearnFrenzy

Esc

Quick links