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 / b sohan lal

#include<iostream.h>
void main()
{
init i,n,k,sum;
clrscr();
sum=0;
cout<<"enter the max limit:";
cin>>n;
i=1;
while(k<=n)
{
k=i*2;
sum=sum+k;
i++;
}
cout<<"result="<<sum;
getch();
}

Is This Answer Correct ?    6 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are vectors used for in c++?

617


What does flush do c++?

551


Write a short code using c++ to print out all odd number from 1 to 100 using a for loop

584


Write about all the implicit member functions of a class?

593


What is the difference between interpreters and compilers?

624






What do you understand by zombie objects in c++?

609


What is java and c++?

658


What is a tuple c++?

540


What do you mean by friend class & friend function in c++?

620


Is c++ proprietary?

575


What is meaning of in c++?

668


How can I learn c++ easily?

618


What is the purpose of templates in c++?

563


What is std :: flush?

574


Explain the pure virtual functions?

634