Professional Documents
Culture Documents
If the user chooses options 1-4, prompt them to enter two numbers and
perform the corresponding arithmetic operation. If the user chooses
option 5, the program should exit. If the user enters an invalid menu
option, display an error message and display the menu again.
Q2
Write a C++ program that prompts the user to enter
a series of integers (positive, negative, or zero) and
calculates the sum of all positive integers entered.
The program should continue to prompt the user for
input until they enter a negative integer, at which
point the program should display the sum (running
total) of all positive integers entered and exit.
Q3
Write a C++ program that produce the
following matrix using nested for-loop
function
X - - - - - - - - - -
- X - - - - - - - - -
- - X - - - - - - - -
- - - X - - - - - - -
- - - - X - - - - - -
- - - - - X - - - - -
- - - - - - X - - - -
- - - - - - - X - - -
- - - - - - - - X - -
- - - - - - - - - X -
- - - - - - - - - - X
4
Q4
Write a program that prompts user to input a character and
the program will print out a matrix such as in Question T2 but
replaces X with the character the user inputs. The output
below is an example if the user inputs ‘j’
- - - - - - - - - - j
- - - - - - - - - j -
- - - - - - - - j - -
- - - - - - - j - - -
- - - - - - j - - - -
- - - - - j - - - - -
- - - - j - - - - - -
- - - j - - - - - - -
- - j - - - - - - - -
- j - - - - - - - - -
j - - - - - - - - - -
5