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 / 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 |
Post New Answer View All Answers
What are guid? Why does com need guids?
Define macro.
What's the order in which the local objects are destructed?
Am studying basic c++ programming, have been given the following assignment. Design a linear program to calculate the maximum stress a material can withstand given a force and a diameter of a circle. To find the required area pi should be defined. Have most of the program sorted out but am at a loss as to how to show the calculations required. Can anyone help?
Should the this pointer can be used in the constructor?
C is to C++ as 1 is to a) What the heck b) 2 c) 10
How we can differentiate between a pre and post increment operators during overloading?
Can we use clrscr in c++?
Is multimap sorted c++?
In which header file does one find isalpha() a) conio.h b) stdio.h c) ctype.h
Explain the use of vtable.
Is c++ still in demand?
What would happen on forgetting [], while deallocating an array through new?
What are the differences between new and malloc?
What is class in c++ with example?