Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi I would like help troubleshooting my C++ code. I created a code that uses while loops to allow the user to input two integers.

Hi I would like help troubleshooting my C++ code. I created a code that uses while loops to allow the user to input two integers. Another while loop is used to find the odd numbers between integer one and integer two and output the square of the odd numbers only. When I run the program it is outputting the square of the even and odd numbers. I am not sure why this is happening. Below my code and output for my code.

#include #include

using namespace std;

int main() { int firstNum; int secondNum; int numRange[100]; int difference; int squareOdd; int n = 1; int i = 0; while(i > firstNum; cout > secondNum; difference = (secondNum - firstNum); i++; } i = 1; while(i = 1) squareOdd = 0; squareOdd = pow(numRange[i],2); cout

return 0; }

image text in transcribed
input Please enter the first integer (must be smaller than second integer ) : 1 Please enter the second integer (must be bigger than first intger: 10 4 9 16 25 36 49 64 81 . . . Program finished with exit code 0 Press ENTER to exit console

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

2. What is The Body Shop's competitive strategy?

Answered: 1 week ago