63 845
Assignments Done
99,2%
Successfully Done
In August 2018

Answer to Question #8728 in C++ for Faris Al-Raqqad

Question #8728
Write a program that uses while loop that prompts the user to input two integers x, and y. Then output all odd numbers between x and y.
Expert's answer
#include <iostream>
using namespace std;

int main() {
char
answer = 'y';
int x;
int y;
while (answer != 'n') {
cout << "x
= ";
cin >> x;
cout << "y = ";
cin >> y;
if (x
> y) {
int c = x;
x = y;
y = c;
}
cout << "Odd number
between x and y: ";
for (int i = x + 1; i < y; i++)
if (i % 2 !=
0)
cout << i << " ";
cout << endl;
cout <<
"Once more?(y/n) ";
cin >> answer;
}
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions