09-27-2020 02:04 AM
How do I make a program where we can input a number N, so it adds up all odd numbers from 0 to N, using a while loop. For example, if 11 is inputted, then the program returns 36 (1+3+5+7+9+11). Please help me
09-27-2020 04:30 AM - edited 09-27-2020 11:58 AM
What have you tried? What is the problem? How would you solve it with paper&pencil?
Do you have problem generating the numbers?
Do you need to determine if a number is odd or do they occur in some regular pattern?
Can you generate the numbers, but don't know how to sum them?
A FOR loop is probably a better choice because (given N) the total number of iterations can be calculated before the loop starts.
Have a look at the training resources listed on the top of the forum.