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 / ashok ak

#include<iostream>
using namespace std;
int main()
{
int a=0,n;
cout<<"Enter the Number ";
cin>>n;
for(int i=1;i<=n;i++)
a+=pow(i,2);
cout<<"The Sum of Total is "<<a;
return 0;
}

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the oldest programming language?

564


Explain what happens when a pointer is deleted twice?

733


List different attributes in C++?

639


Where are setjmp and longjmp used in c++?

611


What do you mean by early binding?

599






What is the identity function in c++? How is it useful?

548


Which is the best c++ software?

604


How to defines the function in c++?

610


Program to check whether a word is a sub-string or not of a string typed

1592


How can a called function determine the number of arguments that have been passed to it?

655


What is the maximum combined length of command line arguments including the space between adjacent arguments?

590


What's c++ used for?

589


Explain the difference between overloading and overriding?

607


What's the best free c++ profiler for windows?

618


Explain how the virtual base class is different from the conventional base classes of the opps.

679