Inactive Tutor answered 07/10/25
#include <iostream>
using namespace std;
int main() {
int sum = 0;
for (int i = 1; i <= 1000; i++) {
sum += i;
}
cout << "Sum from 1 to 1000 using for loop: " << sum << endl;
return 0;
}
First try to understand the question and express it in your own words, next try to solve the question and formulate some math related expressions starting from input-> process--> output arrangement (this is formulating algorithm), then use graphical method to describe the step by step arrangement you already have at the algorithm phase. Finally, start coding using appropriate header file, variable declaration and initialization, and apply proper syntax rules.
Inactive Tutor answered 07/10/25
#include <iostream>
using namespace std;
int main() {
int sum = 0;
for (int i = 1; i <= 1000; i++) {
sum += i;
}
cout << "Sum from 1 to 1000 using for loop: " << sum << endl;
return 0;
}
Inactive Tutor answered 03/12/25
#include<iostream>
using namespace std;
int main()
{
int sum = 0;
for(int i=1; i<=1000; i++)
{
sum = sum + i;
}
cout<<"The Sum is: "<<sum;
return 0;
}
Get a free answer to a quick problem.
Most questions answered within 4 hours.
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.