//Write a program to calculate the sum of squares of integers 1 to n. where n is the value entered by user. i.e(sum=12+22+32+42+52................n2).
#include <iostream>
using namespace std;
int main()
{
int num,sum=0;
cout << "Enter The value of n: ";
cin >>num;
for (int i=1;i<=num;i++)
{
sum=sum+(i*i);
}
cout << "Sum is: " << sum <<endl;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int num,sum=0;
cout << "Enter The value of n: ";
cin >>num;
for (int i=1;i<=num;i++)
{
sum=sum+(i*i);
}
cout << "Sum is: " << sum <<endl;
return 0;
}
0 comments:
Post a Comment
Thanks For Your FeedBack....
Click to see the code!
To insert emoticon you must added at least one space before the code.