Using C++ Write a program that uses for loops to perform the following steps

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter8: Advanced Method Concepts
Section: Chapter Questions
Problem 8RQ
icon
Related questions
Question

Using C++ Write a program that uses for loops to perform the following steps

V
ols
Programming Exercise 5-9
Instructions
U
!!!
3
</>
gº
?
to perform the following steps:
1. Prompt the user to input two
integers: firstNum and
secondNum
o (firstNum must be less than
secondNum ).
2. Output all odd numbers between
firstNum and secondNum.
3. Output the sum of all even numbers
between firstNum and
secondNum
4. Output the numbers and their
squares between 1 and 10.
o Separate the numbers using any
amount of spaces.
5. Output the sum of the square of the
odd numbers between firstNum
and secondNum
6. Output all uppercase letters.
1 #incluc
2
3 using n
4
5 int mair
main.cpp
7
6885
8}
9
// W
retu
Transcribed Image Text:V ols Programming Exercise 5-9 Instructions U !!! 3 </> gº ? to perform the following steps: 1. Prompt the user to input two integers: firstNum and secondNum o (firstNum must be less than secondNum ). 2. Output all odd numbers between firstNum and secondNum. 3. Output the sum of all even numbers between firstNum and secondNum 4. Output the numbers and their squares between 1 and 10. o Separate the numbers using any amount of spaces. 5. Output the sum of the square of the odd numbers between firstNum and secondNum 6. Output all uppercase letters. 1 #incluc 2 3 using n 4 5 int mair main.cpp 7 6885 8} 9 // W retu
!!!!!!
|././
3
1/
gº
?
seconunum).
2. Output all odd numbers between
firstNum and secondNum
3. Output the sum of all even numbers
between firstNum and
secondNum
4. Output the numbers and their
squares between 1 and 10.
o Separate the numbers using any
amount of spaces.
5. Output the sum of the square of the
odd numbers between firstNum
and secondNum
6. Output all uppercase letters.
Grading
When you have completed your
program, click the Submit button to
record your score.
K
7
L6980
1#
3 u
4
5 ir
123
8}
2
±
Transcribed Image Text:!!!!!! |././ 3 1/ gº ? seconunum). 2. Output all odd numbers between firstNum and secondNum 3. Output the sum of all even numbers between firstNum and secondNum 4. Output the numbers and their squares between 1 and 10. o Separate the numbers using any amount of spaces. 5. Output the sum of the square of the odd numbers between firstNum and secondNum 6. Output all uppercase letters. Grading When you have completed your program, click the Submit button to record your score. K 7 L6980 1# 3 u 4 5 ir 123 8} 2 ±
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

How do I print the Uppercase letters without the commas?

Solution
Bartleby Expert
SEE SOLUTION
Follow-up Question

Thank you. It also asks to 'output all uppercase letters' in case 1 and 2.

Test Case 1 has inputs 

4

36

Test Case 2 has inputs 

987

1001

The pictures I sent is the algorithm you've sent

main.cpp
1 #include <iostream>
2
3 using namespace std;
4
5 int main()
6
67891pnvsuuuu
{
210
11
12
13
gº
14
15
18
19
20
21
22
23
24
25
26
int firstNum, secondNum, evenSum = 0, oddSumSquare= 0;
cout<<"ENTER FIRST NUMBER ";
cin>>firstNum;
cout<<"ENTER SECOND NUMBER: ";
+
cin>>secondNum;
cout<<"ODD NUMBER BETWEEN "<<firstNum<<" AND `"<<secondNum<<endl;
while(firstNum<=secondNum) {
if(firstNum%2 != 0) {
oddSumSquare += firstNum*firstNum;
cout<<firstNum<<" ";
}
}
else{
}
evenSum += firstNum;
firstNum++;
cout<<"\nSUM OF ALL EVEN NUMBERS BETWEEN "<<firstNum<<" AND "<<secondNum<<" = "<<evenSum<<endl;
cout<<"PRINT NUMBER AND THEIR SQUARE BETWEEN 1 AND 10"<<endl;
for(int i=1; i <=10; i++) {
cout<<i<<": "<<i*i<<endl;
O
C
▬▬
hp
99+
a
I
W
Transcribed Image Text:main.cpp 1 #include <iostream> 2 3 using namespace std; 4 5 int main() 6 67891pnvsuuuu { 210 11 12 13 gº 14 15 18 19 20 21 22 23 24 25 26 int firstNum, secondNum, evenSum = 0, oddSumSquare= 0; cout<<"ENTER FIRST NUMBER "; cin>>firstNum; cout<<"ENTER SECOND NUMBER: "; + cin>>secondNum; cout<<"ODD NUMBER BETWEEN "<<firstNum<<" AND `"<<secondNum<<endl; while(firstNum<=secondNum) { if(firstNum%2 != 0) { oddSumSquare += firstNum*firstNum; cout<<firstNum<<" "; } } else{ } evenSum += firstNum; firstNum++; cout<<"\nSUM OF ALL EVEN NUMBERS BETWEEN "<<firstNum<<" AND "<<secondNum<<" = "<<evenSum<<endl; cout<<"PRINT NUMBER AND THEIR SQUARE BETWEEN 1 AND 10"<<endl; for(int i=1; i <=10; i++) { cout<<i<<": "<<i*i<<endl; O C ▬▬ hp 99+ a I W
7 int firstNum, secondNum, evenSum = 0, oddSumSquare= 0;
cout<<"ENTER FIRST NUMBER '";
cin>>firstNum;
cout<<"ENTER SECOND NUMBER: ";
cin>>secondNum;
cout<<"ODD NUMBER BETWEEN "<<firstNum<<" AND "<<secondNum<<endl;
while(firstNum<=secondNum) {
if(firstNum%2 != 0) {
oddSumSquare += firstNum*firstNum;
cout<<firstNum<<" ";
BAHARNING
10
12
13
14
16
C
@
26
27
28
29
30
31}
32
}
}
else{
}
evenSum += firstNum;
}
firstNum++;
cout<<"\nSUM OF ALL EVEN NUMBERS BETWEEN "<<firstNum<<" AND "<<secondNum<<" = "<<evenSum<<endl;
cout<<"PRINT NUMBER AND THEIR SQUARE BETWEEN 1 AND 10"<<endl;
for(int i=1; i<=10; i++) {
cout<<i<<" : "<<i*i<<endl;
cout<<"\nSUM OF THE SQUARE OF ALL ODD NUMBERS BETWEEN "<<firstNum<<" AND "<<secondNum<<": "<<oddSumS
return 0;
O
CO
70
Cop
99+
a
W
Transcribed Image Text:7 int firstNum, secondNum, evenSum = 0, oddSumSquare= 0; cout<<"ENTER FIRST NUMBER '"; cin>>firstNum; cout<<"ENTER SECOND NUMBER: "; cin>>secondNum; cout<<"ODD NUMBER BETWEEN "<<firstNum<<" AND "<<secondNum<<endl; while(firstNum<=secondNum) { if(firstNum%2 != 0) { oddSumSquare += firstNum*firstNum; cout<<firstNum<<" "; BAHARNING 10 12 13 14 16 C @ 26 27 28 29 30 31} 32 } } else{ } evenSum += firstNum; } firstNum++; cout<<"\nSUM OF ALL EVEN NUMBERS BETWEEN "<<firstNum<<" AND "<<secondNum<<" = "<<evenSum<<endl; cout<<"PRINT NUMBER AND THEIR SQUARE BETWEEN 1 AND 10"<<endl; for(int i=1; i<=10; i++) { cout<<i<<" : "<<i*i<<endl; cout<<"\nSUM OF THE SQUARE OF ALL ODD NUMBERS BETWEEN "<<firstNum<<" AND "<<secondNum<<": "<<oddSumS return 0; O CO 70 Cop 99+ a W
Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Types of Loop
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,