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 is expression parser in c++
How will you call C functions from C ++ and vice-versa?
Explain deep copy and a shallow copy?
What is a storage class? Mention the storage classes in c++.
Differentiate between an external iterator and an internal iterator? What is the advantage of an external iterator.
What is the difference between an external iterator and an internal iterator?
What are the extraction and insertion operators in c++? Explain with examples.
Why do we learn c++?
What is class and structure in c++?
Write a function to find the nth item from the end of a linked list in a single pass.
Differences between private, protected and public and give examples.
Give the difference between the type casting and automatic type conversion. Also tell a suitable C++ code to illustrate both.
What are virtual constructors/destructors?
How can I learn dev c++ programming?
Why c++ is called oop?