0% found this document useful (0 votes)
34 views2 pages

Applications 03

The document contains 9 questions asking the student to write C++ programs to perform various tasks involving conditional logic, mathematical equations, arrays, and sorting numbers. The questions cover topics like determining if a number is even or odd, calculating values of equations based on conditions, prompting user input with a switch statement, calculating geometric shapes based on user selection, and sorting numbers in increasing order.

Uploaded by

Ahmet Erkliğ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views2 pages

Applications 03

The document contains 9 questions asking the student to write C++ programs to perform various tasks involving conditional logic, mathematical equations, arrays, and sorting numbers. The questions cover topics like determining if a number is even or odd, calculating values of equations based on conditions, prompting user input with a switch statement, calculating geometric shapes based on user selection, and sorting numbers in increasing order.

Uploaded by

Ahmet Erkliğ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CLASSWORK APPLICATIONS FOR SELECTIVE STRUCTURES

Q1. Write a C++ program to determine a given number is odd or even.

Q2. Write a C++ program that determines whether a given temperature is less than or greater
than the room temperature (25°C ). If it is exaclty equal to the room temperature, the program
displays “the temperature is good!”. If it is less than rooom temperature, the program displays
“increase the temperature”. If it is greater, the program displays “decrease the temperature”.

Q3. Write the C++ program required to calculate y(t) from the equation

− 4t 3 + 3 t ≤ 0

y(t)=  4t 3 + 3 0 < t < 2
 17.5t t ≥ 2


for any values of t.

Q4. In a mechanical engineering department, a student must enroll for three elective courses
during the last term. The student must select three courses from following list of options:

ME 401 KIN. SYNTHESIS OF LINKAGE

ME 405 MECHANICAL VIBRATIONS

ME 407 ELEC.ACTUATIONS OF MECH.SYS.

ME 408 STRENGTH OF MATERIALS 2

ME 410 CENTRIFUGAL PUMP BLOWER

Construct a C++ p rogram that prompts the student for his or her choice, read in the choice,
and use the answer as the case expression for a switch construct. Be sure to include a default
case to handle invalid inputs.

Q5. Write a program to read one of the codes “C” for circle, “S” for square, or “T” for a
triangle, and a number representing the radius of the circle, the side of the square, or the sides
of the triangle, respectively. Then calculate and display the area and the perimeter of that
geometric figure with appropriate labels.

Q6. Write a C++ program required to calculate y(α) from the equation
Tan(α ) α ≠ π , 3π
 2 2
y(α)= 
Undefined α = π , 3π
 2 2

for any values of α .

Q7. In a shop, the products are coded as follows:

Code Name Price

01 LCD 1050

02 Radio 55

03 VCD 150

04 Telephone 75

05 Fax 150

06 Harddisk 130

Write a C++ program to learn the product name and its price when the product code is
entered.

Q8. Write a C++ program that determines whether a given number is divisible by 15 or not.

Q9. Write a program to order three arbitrary numbers that are input from keyboard. Use an
increasing order.

You might also like