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.
1
Expert's answer
2012-04-26T07:37:25-0400
#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; }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment