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
What does namespace mean in c++?
Can a new be used in place of old mallocq? If yes, why?
What is #include c++?
What is the size of integer variable?
Does c++ have foreach?
Can I have a reference as a data member of a class? If yes, then how do I initialise it?
How do you initialize a string in c++?
What is the full form of dos?
Explain the concept of friend function in c++?
How should a contructor handle a failure?
Do you know the use of vtable?
What is the use of pointer in c++ with example?
Why is c++ is better than c?
Explain some examples of operator overloading?
Are there interfaces in c++?