04-24-2011, 06:31 PM
Dear Student,
It may not necessarily be a problem with your Dev C++ IDE. The difference in the version of Dev does not make much of an affect. I think that the issue is with the code which you are compiling may contains soem syntax errors. Another important thing you should keep in mind is to add the line using namespace std; at the top of your each program and also write the following line system("pause"); before the closing curly brace '}' of the program.
Below is the correct code of the above mentioned program. Just compile and run it to see if it works.
#include <iostream.h>
using namespace std; // this line was missing in your code
main()
{
int sum, number;
sum = 0;
number = 1;
while(number <= 1000)
{
sum = sum + number;
number = number + 1;
}
cout << "The sum of first 1000 integers starting from 1 is " << sum;
system("pause");// this line should also be written to halt the output screen so that you can see the program output
}
It may not necessarily be a problem with your Dev C++ IDE. The difference in the version of Dev does not make much of an affect. I think that the issue is with the code which you are compiling may contains soem syntax errors. Another important thing you should keep in mind is to add the line using namespace std; at the top of your each program and also write the following line system("pause"); before the closing curly brace '}' of the program.
Below is the correct code of the above mentioned program. Just compile and run it to see if it works.
#include <iostream.h>
using namespace std; // this line was missing in your code
main()
{
int sum, number;
sum = 0;
number = 1;
while(number <= 1000)
{
sum = sum + number;
number = number + 1;
}
cout << "The sum of first 1000 integers starting from 1 is " << sum;
system("pause");// this line should also be written to halt the output screen so that you can see the program output
}
