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
Explain operator overloading.
What are the two types of comments, and how do they differ?
What is a tree in c++?
Show the declaration for a pointer to function returning long and taking an integer parameter.
Can I learn c++ as my first language?
What is vector string in c++?
Who made c++?
Which operations are permitted on pointers?
Evaluate the following expression as C++ would do :8 * 9 + 2 * 5 a) 82 b) 79 c) 370 d) list
What is the need of a destructor? Explain with the help of an example.
What is iomanip c++?
What does asterisk mean in c++?
What is c++ vb?
Difference between delete and free.
Evaluate as true or false: !(1 &&0 || !1) a) True b) False c) Invalid statement