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 you mean by inheritance in c++?

810


When to use “const” reference arguments in a function?

793


What are the various arithmetic operators in c++?

792


Are there interfaces in c++?

742


Write down the equivalent pointer expression for referring the same element a[i][j][k][l]?

952


Explain the differences between private, public and protected and give examples.

766


Define copy constructor.

846


How do you traverse a btree in backward in-order?

817


What is the difference between passing by reference and passing a reference?

769


What is the first name of c++?

761


What are the uses of c++ in the real world?

768


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

833


what is C++ objects?

892


You run a shell on unix system. How would you tell which shell are you running?

886


What are friend functions in C++?

811