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

What is a dll entry point?

564


What is a stack c++?

578


Why is it necessary to use a reference in the argument to the copy constructor?

637


Difference between an inspector and a mutator

779


Why do we use classes in programming?

578






What is a set in c++?

533


What is the use of ::(scope resolution operator)?

655


What is the use of seekg in c++?

600


What is a lambda function c++?

555


What is a c++ map?

664


Differentiate between structure and class in c++.

604


Write a Program for find and replace a character in a string.

559


Search for: what is pair in c++?

595


Is there a sort function in c++?

553


Why is "using namespace std;" considered bad practice?

656