### Can someone help me with this program

The user is prompted to enter 2 integers a and b such that a < b.

Using these as starting and final values you are to set up a for loop

that does the following.

1. Evaluate f(x) = 3x2 +2x -4 where x is the current loop value

and display the result as in this example

x =2 then f(x) = 12

2. Display the sum of the squares from a2 to b2

Example if a=2 and b= 4

Output the sum of the squares from 2 to 4 = 29

How much have you written so far?
For example I could help but I do not see what is the problem of your code.
include<iostream>
include<iomanip>

using namespace std;
int main()
{
int f=0,x;
for( int x=1; x<15; x++)
f= 3*(x*x)+2*(x)-4

system("pause");
}

Your problem requires to to ask the user for two numbers and then loop from the lowest to the highest. Try doing the 'ask the user for two numbers' part first.
#include<iostream>
using namespace std;
int main()
{
int a,b,f,y=0;
cout<<endl<<endl<<endl;
cout<<"Enter an integer: ";
cin>>a;
cout<<"Enter a greater integer: ";
cout<<endl<<endl;
cin>>b;
for( int x=a; x<=b; x++)
{f= 3*(x*x)+2*(x)-4;
cout<<"x= "<<x<<" then f(x)= "<<f<<endl;}
cout<<endl<<endl<<endl;
for( int x=a; x<=b; x++)
{y= y+x*x;
cout<<"x= "<<x<<" then x^2= "<<x*x<<endl;}
cout<<endl<<endl<<endl;
cout<<"The sum of the squares from 1 to 8 is: "<<y<<endl;
system("pause");
return 0;
}
Topic archived. No new replies allowed.