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
How does atoi function work?
What is the use of seekg in c++?
Why use of template is better than a base class?
What is function declaration in c++ with example?
Can member data be public?
What does h mean in maths?
What is split a string in c++?
What is the purpose of ios::basefield in the following statement?
Differentiate between the manipulator and setf( ) function?
What are the various operations performed on stack?
What is the copy-and-swap idiom?
Write a program using GUI concept for the scheduling algorithms in Operating system like SJF,FCFS etc..
How does java differ from c and c++?
What are c++ manipulators?
the maximum length of a character constant can be a) 2 b) 1 c) 8