Write a program to calculate the following
i want a c++program for this condition
1+4+9+16+….+100

Like this (1^2+2^2)

Hint use function pow(a,b)

Answer Posted / ashok ak

#include<iostream>
using namespace std;
int main()
{
int a=0,n;
cout<<"Enter the Number ";
cin>>n;
for(int i=1;i<=n;i++)
a+=pow(i,2);
cout<<"The Sum of Total is "<<a;
return 0;
}

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the oldest programming language?

570


Which programming language's unsatisfactory performance led to the discovery of c++?

810


Describe delete operator?

625


Do you know what is overriding?

619


What is private, public and protected inheritance?

595






Give the difference between the type casting and automatic type conversion. Also tell a suitable C++ code to illustrate both.

634


How do you remove an element from a set in c++?

584


Define pointers?

613


what do you mean by volatile variable?

588


How do you add an element to a set in c++?

553


Is oops and c++ same?

580


Explain some examples of operator overloading?

647


What is a base class?

606


Can a program run without main function?

623


Explain the concept of friend function in c++?

608