sequation

Write your question here.
this for make a Sequential
but it says that there is a wrong

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  #include<iostream>
using namespace std;

int addition(int a,int b,int n)
{

	for(int g=0;g<=n;g++)
		c=a+b*g;
	return (c);
}
int main ()
{
	
int e;
e=addition(a,b,n)
int c;
	cout<<"Pleae enter the  number of numbers of the sequetial: ";
	//لادخال عدد حدود المتتابعة
	cin>>n>>endl;
	cout<<"Pleas enter first number of the sequential: ";
		//لادخال ا
		cin>>a>>endl;
	cout<<"Pleas enter the basic of sequential: ";
	//لادخال د
	cin>>b>>endl;
	// الحد العام
	cout<<e;
	return 0;
Last edited on
Line 19, 22, 25: only an output stream(like cout,cerr) makes use of an endl, not an input stream like cin, therefore it should be cin>>n; and cin>>b;
From Line 11 downward: variables n,b,a were not declared.
Note that: the declaration of parameters a,b, and n on line 4 isn't the same as in function main, declare them in main() again.
In function addition, variable c was not declared in this scope. declare it before your for statement.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include<iostream>
using namespace std;

int addition(int a,int b,int n)
{
	int c;
	for(int g=0;g<=n;g++)
		c=a+b*g;
	return (c);
}
int main ()
{
	
int e,a,b,n;
e=addition(a,b,n);
	cout<<"Pleae enter the  number of numbers of the sequetial: ";
	//لادخال عدد حدود المتتابعة
	cin>>n;
	cout<<"Pleas enter first number of the sequential: ";
		//لادخال ا
		cin>>a;
	cout<<"Pleas enter the basic of sequential: ";
	//لادخال د
	cin>>b;
	// الحد العام
	cout<<e;
	return 0;
}

i have done all what u told me but a new wrong has found
"Debug Error"
You are using variables a, b and n before they are initialized. Move line 15 between lines 25 and 26.
thx it works :D
but don't as i want i want it in series
Topic archived. No new replies allowed.