
int main();
{
int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t
cout <<"Please enter your first number /n";
cin >> a;
cin.ignore;
cout <<"Please enter your second number /n";
cin >> a;
cin.ignore;int result; //I'm just declaring a global variable
while (a>0);
{
result+=a;
}
//Sorry, I forgot how to end it. Was it something like "endl}"?
while (b>0);
{
result+=b;
}
//And end the loop again...



not_essence2 wrote:I'm pretty sure this goes beyond the simple concept of the loops like "while-do" and into distinguishing positive & negative...
I'm sorry if this has a lot of one-character errors, I haven't revisited my tutorials in a while...
- Code: Select all
int main();
{
int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t
cout <<"Please enter your first number /n";
cin >> a;
cin.ignore;
cout <<"Please enter your second number /n";
cin >> a;
cin.ignore;
... And so on until you get all of the numbers:
- Code: Select all
int result; //I'm just declaring a global variable
while (a>0);
{
result+=a;
}
//Sorry, I forgot how to end it. Was it something like "endl}"?
while (b>0);
{
result+=b;
}
//And end the loop again...
Does that help? Sorry, my syntax is probably way off, but you get the basic idea.
/* Includes and such go here */
int main()
{
int c;
int result;
while(c <= 20)
{
int num;
cout << "Enter a number: " << endl;
cin >> num;
if(num > 0)
{
result += num;
}
c++;
}
cout << "And the final calculation is... " << result << "!" << endl;
return 0;
}

while(a>0);
{
result +=a;
a -=a;
}

not_essence2 wrote:Dang, c3ntipede, got in right before I could fix my mistake.
- Code: Select all
while(a>0)
{
{
result +=a
a -=a
}
endl;
}
That was just a fix for my own code. C3ntipede's is fine as well.
Actually, the "if" loop would probably be better...
if (a > 0)
{
result += a;
}

not_essence2 wrote:Dang, c3ntipede, got in right before I could fix my mistake.
- Code: Select all
while(a>0)
{
{
result +=a
a -=a
}
endl;
}
That was just a fix for my own code. C3ntipede's is fine as well.Actually, the "if" loop would probably be better...
WallShadow wrote:@cent I see what you did there with the c



Users browsing this forum: No registered users and 0 guests