C++ Program to print n odd numbers within range
Program
#include <iostream>
using namespace std;
int main()
{
int start_range, end_range;
cout << "Enter the starting range: ";
cin >> start_range;
cout << "Enter the ending range: ";
cin >> end_range;
cout << "Odd numbers in given range are:" << endl;
for (int i = start_range; i <= end_range; i++)
if (i % 2 != 0)
cout << i << " ";
cout << endl;
return 0;
}
Output
$ g++ print-n-odd-numbers-within-range.cpp
$ ./a.out
Enter the starting range: 4
Enter the ending range: 26
Odd numbers in given range are:
5 7 9 11 13 15 17 19 21 23 25