I am having trouble with implementing the following program with c++ and would like to know how to correctly implement it
I am having trouble with implementing the following program with c++ and would like to know how to correctly implement it
Loop 1 - Enter integers m and n at the keyboard. it is assumed that m < n. Output the numbers m, m+1, m+2, ..., n, then output their sum and average with a label. Each should show calculated value with 2 digits to the right of the decimal point.
Loop 2 - Enter integers m and n at the keyboard. it cannot be assume m < n. Output the odd integers in the range [a, b], where a is the least of m, n and b is the largest of m,n.
Loop 3 - Output the numbers 1.3, 1.5, 1.7, ..., 2.9. Show each with 1 digit to the right of the decimal point.
The program run should look like this
Loop 1
Generating numbers from m to n
Enter m and n: 12 16
Expected: integers from 12 to 16
Actual: 12 13 14 15 16
Sum: 70.00 Average: 14.00
Loop 2
Generating odd numbers in a range entered by the user
Enter m and n: 27 20
Expected: odd integers from 20 to 27
Actual: 21 23 25 27
Loop 3
Generating numbers from 1.3, 1.5, ..., 2.9
Expected: 1.3 1.5 1.7 1.9 2.1 2.3 2.5 2.7 2.9
Actual: 1.3 1.5 1.7 1.9 2.1 2.3 2.5 2.7 2.9
The condition for finding whether a number is odd is num%2!=0
Step by step
Solved in 2 steps