Write an algorithm and draw a flowchart to find and print the sum of squared natural numbers from 1 to 100.
plz answer this.
Answers
Answered by
2
Here is the answer. Hope it's helpful for you.
Please Mark me as brainliest.
Attachments:
Answered by
0
Algorithm:
Step 1: Start
Step 2: Declare a variable sum = 0
Step 3: Start a loop from i = 1 upto i = 10
Step 4: Calculate sum
sum = sum + (i * i)
Step 5: Repeat step 3 and 4 till the condition is true
Step 6: Print sum
Step 7: End
Program in C++:
#include<iostream>
using namespace std;
int main()
{
int sum = 0;
cout<<"Squared natural numbers are : ";
for(int i = 1; i <= 10; i++)
{
sum = sum + (i * i);
cout<<i*i<<" ";
}
cout<<"\nSum : "<<sum;
return 0;
}
Output:
Squared natural numbers are : 1 4 9 16 25 36 49 64 81 100
Sum : 385
Attachments:
Similar questions