Question 1: I have written the code but it turned out very complex. Can anyone tell me if I did good or bad? And how would I print out number 1 in my code?
Question 2: Also can anyone show me any other code that is more simple?
#include <iostream>
int main()
{
int start ;
std::cout << "enter starting number: " ;
std::cin >> start ;
int end ;
std::cout << "enter ending number: " ;
std::cin >> end ;
// print all odd numbers in [start,end]
std::cout << "odd numbers in [" << start << ',' << end << "] are\n" ;
// 1. get to the next number if start is even (make it odd)
if( start%2 == 0 ) ++start ;
// 2. loop from start (which is guaranteed to be odd) to end in steps of two
for( int n = start ; n <= end ; n += 2 ) std::cout << n << '\n' ;
}