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 / chaithanya kumar

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

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

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do c++ programmers do?

558


Explain differences between alloc() and free()?

580


What is the best book for c++ beginners?

579


What is the difference between structure and class?

562


Is atoi safe?

603






Which bit wise operator is suitable for turning off a particular bit in a number?

645


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the maximum number of concurrent threads that the InnoDB plug-in can create

2075


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

637


Differentiate between an inspector and a mutator ?

709


What is purpose of abstract class?

586


Should I learn c or c++ or c#?

559


How do you clear a set in c++?

605


What c++ is used for?

587


Can you sort a set c++?

532


Explain the concept of memory leak?

631