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 / yogeshwaran
#include<iostream>
using namespace std;
#include<math.h>
main()
{
double j=0,l=0;
double k=0;
int max=0;
cout<<"enter a maximum value"<<endl;
cin>>max;
for(int i=1;l<=max;i++)
{
j=pow(i,2);
l=j;
j=j+k;
k=j;
}
cout<<"value is "<<j<<endl;
}
| Is This Answer Correct ? | 42 Yes | 5 No |
Post New Answer View All Answers
What are default parameters? How are they evaluated in c++ function?
What is null c++?
What is function overloading in C++?
Can the creation of operator** is allowed to perform the to-the-power-of operations?
Is vector a class in c++?
What do you mean by global variables?
What are multiple inheritances (virtual inheritance)?
What is the oldest programming language?
Mention the storage classes in c++.
What is a far pointer? where we use it?
You have two pairs: new() and delete() and another pair : alloc() and free(). Explain differences between eg. New() and malloc()
What is the best book for c++ beginners?
what is C++ objects?
Can we use struct in c++?
Explain virtual class and friend class.