0% found this document useful (0 votes)
87 views

Functions Exercise

The document describes 5 exercises involving C++ functions: 1. A program that chooses a random arithmetic operation, prompts the user for two numbers, performs the operation, displays the result, and allows the user to continue or terminate. 2. A function to sort 10 integer, long, or double values. 3. A function that receives a factor and outputs its multiplication table up to 10. 4. Modifies #3 to generate a random factor from 1-10 instead of a fixed factor. 5. Further modifies #4 to generate a random factor from 10-99.

Uploaded by

Yen Aduana
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)
87 views

Functions Exercise

The document describes 5 exercises involving C++ functions: 1. A program that chooses a random arithmetic operation, prompts the user for two numbers, performs the operation, displays the result, and allows the user to continue or terminate. 2. A function to sort 10 integer, long, or double values. 3. A function that receives a factor and outputs its multiplication table up to 10. 4. Modifies #3 to generate a random factor from 1-10 instead of a fixed factor. 5. Further modifies #4 to generate a random factor from 10-99.

Uploaded by

Yen Aduana
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

C++ Functions Exercises

1. The program will choose a random operation(either Addition, Subtraction, Multiplication,


Division, or Modulus in functions). Then it asks the user to input two integer values for the
calculation(call a function operation). The program also asks the user to decide whether
he/she wants to continue the operation. If he/she input ‘y’, the program will choose and prompt
a random operation again. Otherwise, the program will terminate.

Example:

Random Operation: Addition

Enter your two numbers: 12 15

Result: 27

2. Write a C++ functions to sort 10 integer values, or 10 long values, or 10 double values.

3. Write a C++ program with a function that receives a factor and will output the multiplication
table as shown below:

Enter the factor: 3

3*1=3

3*2=6

3*3=9

3 * 4 = 12

3 * 10 = 30

4. Modify the problem in #3, such that it will generate random number as a factor from 1-10, and
call the function that receives a factor and will output the multiplication table as shown below:

Random factor: 5

5*1=5

5 * 2 = 10

5 * 3 = 15

5 * 4 = 20

.
.

5 * 10 = 50

5. Modify the problem in #4, such that it will generate random number as a factor from 10-99, and
call the function that receives a factor and will output the multiplication table as shown below:

Random factor: 33
33 * 1 = 33
33 * 2 = 66
33 * 3 = 99
33 * 4 = 132
.
.
.
33 * 10 = 330

You might also like