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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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

### Programming Exercise 5-9

#### Instructions

To complete this exercise, follow the steps below:

1. **Input Two Integers**:  
   Prompt the user to input two integers: `firstNum` and `secondNum`.  
   - Ensure that `firstNum` is less than `secondNum`.

2. **Output Odd Numbers**:  
   Output all odd numbers between `firstNum` and `secondNum`.

3. **Sum of Even Numbers**:  
   Output the sum of all even numbers between `firstNum` and `secondNum`.

4. **Numbers and Their Squares**:  
   Output the numbers and their squares between 1 and 10.  
   - Separate the numbers using any amount of spaces.

5. **Sum of Squares of Odd Numbers**:  
   Output the sum of the square of the odd numbers between `firstNum` and `secondNum`.

6. **Output Uppercase Letters**:  
   Display all uppercase letters.
Transcribed Image Text:### Programming Exercise 5-9 #### Instructions To complete this exercise, follow the steps below: 1. **Input Two Integers**: Prompt the user to input two integers: `firstNum` and `secondNum`. - Ensure that `firstNum` is less than `secondNum`. 2. **Output Odd Numbers**: Output all odd numbers between `firstNum` and `secondNum`. 3. **Sum of Even Numbers**: Output the sum of all even numbers between `firstNum` and `secondNum`. 4. **Numbers and Their Squares**: Output the numbers and their squares between 1 and 10. - Separate the numbers using any amount of spaces. 5. **Sum of Squares of Odd Numbers**: Output the sum of the square of the odd numbers between `firstNum` and `secondNum`. 6. **Output Uppercase Letters**: Display all uppercase letters.
**Instructions**

1. Output all odd numbers between `firstNum` and `secondNum`.

2. Output the sum of all even numbers between `firstNum` and `secondNum`.

3. Output the numbers and their squares between 1 and 10.
   - Separate the numbers using any amount of spaces.

4. Output the sum of the square of the odd numbers between `firstNum` and `secondNum`.

5. Output all uppercase letters.

**Grading**

When you have completed your program, click the **Submit** button to record your score.
Transcribed Image Text:**Instructions** 1. Output all odd numbers between `firstNum` and `secondNum`. 2. Output the sum of all even numbers between `firstNum` and `secondNum`. 3. Output the numbers and their squares between 1 and 10. - Separate the numbers using any amount of spaces. 4. Output the sum of the square of the odd numbers between `firstNum` and `secondNum`. 5. Output all uppercase letters. **Grading** When you have completed your program, click the **Submit** button to record your score.
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.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education