C++
-
:confused:I need to write a program that reads n from the keyboard and prints on the screen the sum of numbers 1 + 4 + 7 + ... + (3n-2). Compile it and run it What is the result for n=7 and n=98
huh! where's the programming question please ? write some code, and we'll be happy to help you ! say that it's not a homework assigment !? Max
-
huh! where's the programming question please ? write some code, and we'll be happy to help you ! say that it's not a homework assigment !? Max
the "compile it and run it" line at the end makes it look like homework to me! -- Help me! I'm turning into a grapefruit!
-
:confused:I need to write a program that reads n from the keyboard and prints on the screen the sum of numbers 1 + 4 + 7 + ... + (3n-2). Compile it and run it What is the result for n=7 and n=98
Here's the program:
int n; cin >> n; cout << "The result is" << (3 * n * n - n)/2 << endl;
Best regards, Alexandru Savescu