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 do you mean by inheritance in c++?
When to use “const” reference arguments in a function?
What are the various arithmetic operators in c++?
Are there interfaces in c++?
Write down the equivalent pointer expression for referring the same element a[i][j][k][l]?
Explain the differences between private, public and protected and give examples.
Define copy constructor.
How do you traverse a btree in backward in-order?
What is the difference between passing by reference and passing a reference?
What is the first name of c++?
What are the uses of c++ in the real world?
What is the use of ::(scope resolution operator)?
what is C++ objects?
You run a shell on unix system. How would you tell which shell are you running?
What are friend functions in C++?