need a second pair of eyes! help!!!1

my code is short, but i cannot find whats wrong..

#include<iostream>
int main()
int sum=value=0;
char stop='n';
cout<<"Give an integer for n,the number of values you will input\n";
int n;
cin>>n;
for(int i=0;i<=n&&stop='n',i++)
{
cout<<input integer(i+1)<<endl;
cin>>value;
sum+=value;
cout<<"The sum so far is"<<sum
<<" Do you want to stop now?(y/n)"<<endl<<;
cin>>stop;
if(stop=='n') then i=n;
}
cout<<"The final sum is"<<sum<<endl;
Last edited on
why there is no Space and '{'
e.g intmain() is like int main()
what is inoutinteger?
make it clear using code tags.
whoops here it is again
#include<iostream>
int main()
int sum=value=0;
char stop='n';
cout<<"Giveanintegerforn,thenumberofvaluesyouwillinput\n";
int n;
cin>>n;
for (int i=0;i<=n && stop='n',i++)
{
cout<<input integer (i+1)<<endl;
cin>>value;
sum+=value;
cout<<"The sum so far is"<<sum
<<" Do you want to stop now?(y/n)"<<endl<<;
cin>>stop;
if(stop=='n') then i=n;
}
cout<<"The final sum is"<<sum<<endl;


PLEASE HELP ME FIX SORRY FOR THE CONFUSION
Last edited on
First, code tags:
http://cplusplus.com/articles/z13hAqkS/

Second, what is the error?
The error resides here:
int main()

You have no scope for main, it's a wonder that you don't have numerous errors. And as firedraco pointed out, please remember to use code tags from now on.
you can't do
int sum=value=0

you have to define value first or do like this
int sum=0,value=0;


for(int i=0;i<=n&&stop='n',i++)

no need to include stop condition you are already making i=n;
do that i =n+1 and for loop;
for(int i=0;i<=n,i++)


remove then from your program.
if you still get problem than let me know i will give you corrected code.
Last edited on
word of advice: placing tabs between descending statements/expressions will make your code much more readable and debuggable.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
int main()
{
    return 0;
}

vs 

int main(){return 0;}   //i've seen this done before

vs

int main()
{
return 0;
}


which one is most readable? now think about this for code thousands of lines long and tell me again :}
Last edited on
@DeXecipher: what about
1
2
3
int main(){
return 0;
}
?
If I can add my 2 cents worth :D

you can't do

int sum=value=0;


I thought you could do that, it works because they are assignments.

However it is bad form, I would do this, because it is declaration, initialisation and comment, all in one line>

1
2
int sum = 0; //what does sum mean
int value = 0;    //what does value mean 


HTH (Hope this helps)
@viliml i forgot

1
2
3
int main(){
return 0;
}


is also bad
Topic archived. No new replies allowed.