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


Please Help Members By Posting Answers For Below Questions

There are 100 students in a class. The management keep information in two tables. Those two tables are given like Roll no Name Age 001 ABC 15 002 XYZ 14 and Roll No Subject Marks 001 Math 75 001 Physics 55 002 Math 68 001 Hindi 69 They want the information like this Roll No Name Hindi Physics Math Total 001 ABC 69 55 75 199 002 XYZ 68 74 84 226 And Roll No Suject Highest 001 Math 98 007 Physics 84 021 Hindi 74 All 275 All information is kept in structure in main memory. You have to find last two tables.

2736


Is rust better than c++?

810


What is a try block?

828


Can I have a reference as a data member of a class? If yes, then how do I initialise it?

911


Difference between a homogeneous and a heterogeneous container

886


What is the use of seekg in c++?

792


What is #include iomanip?

746


Refer to a name of class or function that is defined within a namespace?

827


What is the limitation of cin while taking input for character array?

1696


What is a string example?

754


Is c++ pass by reference or value?

772


Do the parentheses after the type name make a difference with new?

842


Why is c++ difficult?

788


What is the difference between interpreters and compilers?

833


Why Pointers are not used in C++?

793