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 / yogeshwaran

#include<iostream>
using namespace std;
#include<math.h>
main()
{
double j=0,l=0;
double k=0;
int max=0;

cout<<"enter a maximum value"<<endl;
cin>>max;
for(int i=1;l<=max;i++)
{
j=pow(i,2);
l=j;
j=j+k;
k=j;
}
cout<<"value is "<<j<<endl;
}

Is This Answer Correct ?    42 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a function to perform the substraction of two numbers. Eg: char N1="123", N2="478", N3=-355(N1-N2).

625


What is the importance of mutable keyword?

592


What is an accessor in c++?

624


What is the purpose of ios::basefield in the following statement?

798


What are the benefits of operator overloading?

688






What is a multiset c++?

561


How much is c++ certification?

593


Is there structure in c++?

600


Differentiate between a template class and class template in c++?

636


What are the general quetions are in DEna bank manager IT/System interviews?

1542


What causes a runtime error c++?

595


What is the difference between a template and a macro?

591


What is a local variable?

582


What is pair in c++?

639


What are the differences between java and c++?

540