### sum of odd numbers between 2 integers

Hey guys,

I have an assignment for practice with for loop. I'm extremely new to c++ world and any help for this assignment is much appreciated.

Assignment states that:

Both numbers must be positive
First number must be less than the second

Ex: Valid user input: 3, 13. Ouput 3+5+7+9+11+13 = 48
Ex: Valid user input: 4, 13. Output 5+7+9+11+13 = 45

I know how to set the numbers to be positive but I'm kinda struggling with the rest. Again, Any help is much much appreciated!
Last edited on
 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859`` ``````/* Usandfriends */ #include int main(void) { int low,high,num,total; std::cout<<"This program prints the odd numbers between two positive numbers and the total sum."<>low; std::cin.ignore(); if(low>=0) { break; } std::cout<<"The numbers have to be positive."<>high; std::cin.ignore(); if(high>low) { break; } std::cout<<"The number has to be greater than "<
Last edited on
thanks a bunch!
Topic archived. No new replies allowed.