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
Should the this pointer can be used in the constructor?
Difference between an inspector and a mutator
What are the various storage classes in C++?
What is increment operator in c++?
Where can I run c++ program?
Why is main an int?
How do I use arrays in c++?
Explain the uses oof nested class?
Declare a class vehicle and make it an abstract data type.
How the virtual functions maintain the call up?
What is the most common mistake on c++ and oo projects?
Draw a flow chart and write a program for the difference between the sum of elements with odd and even numbers. Two dimensional array.
What is wrapper class in c++?
How can I learn c++ easily?
What is the use of map in c++?