Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Control structure exercise

1

1. Read an integer value. Assume it is the number of a month of the year; print out the name
of that month.
2. Write a program which reads two integer values. If the first is less than the second, print
the message up. If the second is less than the first, print the message down If the numbers
are equal, print the message equal.
3. Write a C++ program which when two integers x and y are input will output the absolute
difference of the two integers. That is whichever one of (x-y) or (y-x) is positive.
Think of all the cases that can arise and consequently plan a set of test data to confirm the
correctness of your program.
4. Percentage marks attained by a student in three exams are to be entered to a computer.
An indication of Pass or Fail is given out after the three marks are entered. The criteria
for passing are as follows:
A student passes if all three examinations are passed. Additionally a student may pass if
only one subject is failed and the overall average is greater than or equal to 50. The pass
mark for an individual subject is 40.

You might also like