Question: create a program that inputs a number n and an operand ( + , - or * ) from a user and prints the result

create a program that inputs a number n and an operand (+,- or *) from a user and prints the result of the operation on numbers from 1 to n.
Use three functions:
bool isValidnum(int) Takes the user input as an argument, and returns true if it is a valid selection. Otherwise it returns false.
bool isValidop(char) Takes the user operand input as an argument, and returns true if it is a valid selection. Otherwise it returns false.
int result(int, char) Takes the number and the operand as arguments. Performs the required operation, and returns the result.
IMPORTANT!
The functions should not print any value. All the values are printed from the mainfunction.
Do not modify the main function. Write the functions such that they work in the code provided.
Sample Output:
Enter a number [1-100]: 10
Enter an operand [+,-,*]: +
The sum of numbers from 1 to 10 is: 55
Do you want to continue (y / n): y
Enter a number [1-100]: 101
ERROR: Number must be within 1 and 100
Enter a valid number [1-100]: 5
Enter an operand [+,-,*]: /
ERROR: Operand must be either +,- or *
Enter a valid operand [+,-,*]: *
The product of numbers from 1 to 5 is: 120
Do you want to continue (y / n): n

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!