c++ programming if…else and switch case are types of conditional selection statements used in many programming languages such as C++. Write your own codes for question (a), (b) and (c) to demonstrate how the selection statement works. (a) Using if….else selection statement, allow user to key in a number then check whether the number is positive or negative number. (b) Using if….else...if selection statement, allow user to key in a mark for one subject and display the grade for the subject. A for >80, B for >60, C for >50, D for >40, F for <40 ..  (c) Using nested if..else selection statement, ask user to key in their age. Then define whether the user should go to nursery, primary school, secondary school or university based on their input. (d) Using switch case selection statement, allow user to key in a mark for one subject and display the grade for the subject. A for >80, B for >60, C for >50, D for >40, F for <40 .

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 28PE
icon
Related questions
Question

c++ programming

if…else and switch case are types of conditional selection statements used in many programming languages such as C++. Write your own codes for question (a), (b) and (c) to demonstrate how the selection statement works.

(a) Using if….else selection statement, allow user to key in a number then check whether the number is positive or negative number.

(b) Using if….else...if selection statement, allow user to key in a mark for one subject and display the grade for the subject. A for >80, B for >60, C for >50, D for >40, F for <40 .. 

(c) Using nested if..else selection statement, ask user to key in their age. Then define whether the user should go to nursery, primary school, secondary school or university based on their input.

(d) Using switch case selection statement, allow user to key in a mark for one subject and display the grade for the subject. A for >80, B for >60, C for >50, D for >40, F for <40 .

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 4 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr