C++ Program to Print Odd Numbers Between 1 to n
Write C++ Program to Print Odd Numbers Between 1 to n
// CPP Program to Print Odd Numbers Between 1 to n #include <iostream> using namespace std; int main() { int n, i; cout << "Enter the number :--> "; cin >> n; cout << "\nOdd Numbers Between 1 to " << n <<" :--> "; for(i = 1; i<=n; i++) { if(i % 2 != 0) { cout << i << " "; } } return 0; }
Output:
Enter the number :--> 10
Odd Numbers Between 1 to 10 :--> 1 3 5 7 9