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

Explain operator overloading.

606


What are the two types of comments, and how do they differ?

576


What is a tree in c++?

565


Show the declaration for a pointer to function returning long and taking an integer parameter.

582


Can I learn c++ as my first language?

611






What is vector string in c++?

578


Who made c++?

615


Which operations are permitted on pointers?

570


Evaluate the following expression as C++ would do :8 * 9 + 2 * 5 a) 82 b) 79 c) 370 d) list

616


What is the need of a destructor? Explain with the help of an example.

570


What is iomanip c++?

600


What does asterisk mean in c++?

587


What is c++ vb?

616


Difference between delete and free.

619


Evaluate as true or false: !(1 &&0 || !1) a) True b) False c) Invalid statement

639