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
Why is c++ called oops?
C is to C++ as 1 is to a) What the heck b) 2 c) 10
When is the destructor called?
What are protected members in c++?
What is the use of bit fields in structure declaration?
Which is not a valid keyword a) public b) protected c) guarded
What are virtual functions in c++?
If you hear the cpu fan is running and the monitor power is still on, but you did not see anything show up in the monitor screen. What would you do to find out what is going wrong?
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
Why cstdlib is used in c++?
Explain method of creating object in C++ ?
Which is the best c++ software?
What is constructor and destructor in c++?
What is doubly linked list in c++?
How did c++ start?