You are on page 1of 5

ASSIGNMENT 3

Due on Wednesday 10th May 2023,


11.59 PM
Submit in e-learning
Q1
Write a C++ program that presents the user with a menu of options to
perform arithmetic operations on two numbers. The program should
continuously display the menu until the user chooses to exit.

The menu options should include:


1. Add two numbers
2. Subtract two numbers
3. Multiply two numbers
4. Divide two numbers
5. Exit program

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

You might also like