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
What is searching? Explain linear and binary search.
If we want that any wildcard characters in the command line arguments should be appropriately expanded, are we required to make any special provision? If yes, which?
If a round rectangle has straight edges and rounded corners, your roundrect class inherits both from rectangle and from circle, and they in turn both inherit from shape, how many shapes are created when you create a roundrect?
What is c++ map?
What is the difference between a type-specific template friend class and a general template friend class?
In what situations do you have to use initialization list rather than assignment in constructors?
Is dev c++ a good compiler?
How are virtual functions implemented in c++?
What is the role of static keyword for a class member variable?
What is size_type?
Why #include is used?
What is main function in c++ with example?
What is the use of cmath in c++?
What are the three forms of cin.get() and what are their differences?
What is abstraction c++?