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)

Answers were Sorted based on User's Feedback



Write a program to calculate the following i want a c++program for this condition 1+4+9+16+….+1..

Answer / yogeshwaran

#include<iostream>
using namespace std;
#include<math.h>
main()
{
double j=0,l=0;
double k=0;
int max=0;

cout<<"enter a maximum value"<<endl;
cin>>max;
for(int i=1;l<=max;i++)
{
j=pow(i,2);
l=j;
j=j+k;
k=j;
}
cout<<"value is "<<j<<endl;
}

Is This Answer Correct ?    42 Yes 5 No

Write a program to calculate the following i want a c++program for this condition 1+4+9+16+….+1..

Answer / chaithanya kumar

#include<iostream>
#include<math.h>
using namespace std;
main()
{
double j=0,l=0;
double k=0;
int max,i;

cout<<"enter a maximum value"<<endl;
cin>>max;
for(i=1;i<=max;i++)
{
j=pow(i,2);
j=j+k;
k=j;
}
cout<<"value is j= "<<j<<endl;
}

Is This Answer Correct ?    1 Yes 0 No

Write a program to calculate the following i want a c++program for this condition 1+4+9+16+….+1..

Answer / ashok ak

#include<iostream>
using namespace std;
int main()
{
int a=0,n;
cout<<"Enter the Number ";
cin>>n;
for(int i=1;i<=n;i++)
a+=pow(i,2);
cout<<"The Sum of Total is "<<a;
return 0;
}

Is This Answer Correct ?    0 Yes 1 No

Write a program to calculate the following i want a c++program for this condition 1+4+9+16+….+1..

Answer / 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

More C++ General Interview Questions

What are formatting flags in ios class?

0 Answers  


program explaining feautures of c++

0 Answers   Satyam,


If a base class is an adt, and it has three pure virtual functions, how many of these functions must be overridden in its derived classes?

0 Answers  


What is c++ 11 and c++ 14?

0 Answers  


What are references in c++? What is a local reference?

0 Answers  






which is best institue to learn C/C++ IN AMEERPET OR MAITHRIVANAM OR SR NAGAR, PLEASE HELP. THANKS IN ADVANCE

5 Answers  


What is the basic structure of a c++ program?

0 Answers  


There are 100 students in a class. The management keep information in two tables. Those two tables are given like Roll no Name Age 001 ABC 15 002 XYZ 14 and Roll No Subject Marks 001 Math 75 001 Physics 55 002 Math 68 001 Hindi 69 They want the information like this Roll No Name Hindi Physics Math Total 001 ABC 69 55 75 199 002 XYZ 68 74 84 226 And Roll No Suject Highest 001 Math 98 007 Physics 84 021 Hindi 74 All 275 All information is kept in structure in main memory. You have to find last two tables.

0 Answers  


What do c++ programmers do?

0 Answers  


Write a c++ code that will calculate the roots of a quadratic equation a2+ bx+c=0 Hint: d = sqrt (b2-4ac), and the roots are: x1 = (€“b + d)/2a and x2 = (€“b €“ d)/2a (use sqrt function from cmath.h )?

0 Answers   Maxobiz,


Differentiate between an external iterator and an internal iterator?

0 Answers  


check whether a no is prime or not.

3 Answers   TCS,


Categories