ComputerGeek listen to DrChill: READ A TEXT BOOK!
a few notes on your last post
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
#include <iostream>
using namespace std;
int main ()
{
int sum=0;
int a=1;
while(sum>=5000);
a+=a;
a++;
sum=a++;
cin<<first_number;
cout<<totalSum;
cout<<The last number;
return 0;
}
|
First of all your condition in the while loop:
while(sum>=5000);
the condition in the brackets will evaluate to false as you initialised sum as:
int sum=0;
The condition in your while loop is checking weather sum is bigger then 5000, as it is 0 the while loop will not run.
This brings me onto:
while(sum>=5000);
There should be no semicolon at the end of this statement, also if you want the loop to loop through more then one statement use {} to create blocks
like this:
1 2 3 4 5 6 7 8
|
while(sum>=5000)
{
a+=a;
a++;
sum=a++;
}
|
the next three statements are invalid.
1 2 3
|
cin<<first_number;
cout<<totalSum;
cout<<The last number;
|
first_number needs to be declared before it can be used. << opperator is wrongly used with cin.
total sum has not been declared and so cannot be used.
The last number is not a valid identifier for a variable. If you want to print out the text enclose it in " "
PLEASE!, read the basic language tutorial on this website, or in the book DrChill mentioned.