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 class syntax c++?
What is diamond problem in c++?
what are the decision making statements in C++? Explain if statement with an example?
What is abstraction in c++?
What is c++ try block?
What is called array?
Why do we need constructors in c++?
Explain function overloading
Define linked lists with the help of an example.
What is function overloading in C++?
How can I improve my c++ skills?
Is arr and &arr are same expression for an array?
Are strings immutable in c++?
What is auto used for in c++?
What are the two types of comments?