fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int sum,number;
  6. sum = 0;
  7. number =1;
  8.  
  9. while( number <= 1000)
  10. {
  11. sum = sum + number;
  12. number = number + 1;
  13. }
  14. cout << "The sum of the first 1000 integer starting from 1 is" << sum << endl;
  15. return 0;
  16. }
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
The sum of the first 1000 integer starting from 1 is500500