display ODD numbers in the range

Hi, I am new to c++.
I'm having troble with displaying ODD number in give range.
Plz help me!
when I input odd number at first, it will compile correctly. BUT when I put even, it will display even numbers.... how can i fix it??
Here's my code so far.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
using namespace std;

int main()
{
	double x,y;

	while (true)
	{
	cout << endl << "Enter the starting point of the range (double): ";
	cin >> x; cin.ignore(80, '\n');
	cout << "Enter the ending point of the range (double): ";
	cin >> y; cin.ignore(80, '\n');
	while(y <= x)
	{
		cout << "Your ending number must eb greater than your starting number.\n"
			 << "Please try a new ending number: ";
		cin >> y; cin.ignore(80, '\n');
	}
	for (int count = x; count <=y ; count += 2)
	
		cout << count << " ";
		
}
Test to see if starting number is odd or not at first.

Hint: If x mod 2 == 0, then you're number is even

If number is even, add 1 first, then go into your loop. If number is odd, go right into your loop
Thanx!!!!!!

you're my savior!
:)
Topic archived. No new replies allowed.