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 is the oldest programming language?
Which programming language's unsatisfactory performance led to the discovery of c++?
Describe delete operator?
Do you know what is overriding?
What is private, public and protected inheritance?
Give the difference between the type casting and automatic type conversion. Also tell a suitable C++ code to illustrate both.
How do you remove an element from a set in c++?
Define pointers?
what do you mean by volatile variable?
How do you add an element to a set in c++?
Is oops and c++ same?
Explain some examples of operator overloading?
What is a base class?
Can a program run without main function?
Explain the concept of friend function in c++?