I am asking for help with a task :)

Compile a program that prints the screen arithmetic progressions first N members and calculate the amount if the progression of the first member is -10 , but the difference d=2. N entered by the user

Please help urgently :)
closed account (48T7M4Gy)
Ok chief, you just sit back and relax and we'll put our emergency team of programmers onto it right away.
Please help, if I understand myself i dont asking for help
closed account (48T7M4Gy)
I can't believe you are not able to make some sort of a start, even if it is just to write down what an arithmetic progression is. If you don't know then google it. Why should your problem become ours because you are too lazy.

#include <iostream>
#include <stdlib.h>


using namespace std;

int main(int argc, char **argv)
{

int n, number=0;

cout<<"Enter a number N: ";
cin>>n;

cout<<"Arithmetic Progression members: "<<endl;


for (int z=-10; z<n; z=z+2) {

cout<<z<<" ";
number=number+z;

}



cout<<endl<<endl<<the sum of numbers = "<< number;

I now thats not corect but what is wrong pls if you dont want mybee others helps me. I am only 11 and i study by myself in country where not so much info about that.




return 0;
}


You should use a variable unrelated to the calculation of the arithmetic sequence to keep track of the iterations of the for loop:

1
2
3
4
5
6
    int term = -10, difference = 2;
    for (int i=0; i<n; ++i)
    {
        cout << term;
        term += difference;
    }

Topic archived. No new replies allowed.