C++ masterz plz help me ab0ut this questi0n., this is my assignment in 0ur c0mputer pr0gramming that have to pass 0n m0nday june,29,2009... H0w to c0de this? My pr0f want like this: 0nly put 1 n0. Like 9, 11 and s0 on... Ex. If u put less than to 10 this will be print, example y0u put 5 which is less than to 10 the answer will be 5+4+3+2+1 and if y0u put 3 answer will be 3+2+1... That's all please answer... I'm using turb0 C++ and this are s0me c0des ive using:
#include <iostream.h>
void main()
cout
cin
if statement
else if... H0pe y0u can answer i'll w8 4 that thanks
Ok, I'm probably being too generous here, given that I can't be sure you spent more than the 2 minutes it took to type your original post on the project.
Compile and run this:
1 2 3 4 5 6
#include <iostream>
int main() {
for( int i = 0; i < 10; ++i )
std::cout << "i = " << i << std::endl;
}
What you need is only one or two steps beyond that. You need to prompt the user to enter a number (use cout), read the number (use cin), then add up all numbers from 1 to the number they entered (use a for() loop that counts from 1 to that number and add).