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
Show the declaration for a pointer to function returning long and taking an integer parameter.
What does the following code do: int c=0; cout< a) Undefined *Updated* b) 01 c) 00
What is the difference between a template and a macro?
Explain the differences between list x; & list x();.
What is a flag in c++?
What is DlgProc?
What are friend classes?
How can you tell what shell you are running on unix system?
Can class objects be passed as function arguments?
Are there interfaces in c++?
Define a pdb file.
What is virtual methods?
What are the various arithmetic operators in c++?
What is null pointer and void pointer and what is their use?
How can we access protected and private members of a class?