write a program in C++ that computes the minimal and the maximal value of function f(x,y) obtained on an integer point in a given rectangle [a, b] x [c, d]. Your program should prompt the user to input numerical values of a, b, c and d, as floating point numbers, which are expected to be in a range from -100 thru 100. In case when minimal or maximal values do not exists, your program should output appropriate messages.
The calculated integer values of x and y for which f(x,y) reaches its minimum and maximum on [a, b] x [c, d].

a=1, b=10, c=1, d=-20, f(x,y)=2-x+7*x*x-x*x*x;

## All 5 Replies

No one here is going to write a solution for you.

If you have a specific question, post the code you have (in code tags) along with any current errors and people in the community would gladly help you see how to fix what's wrong.

This website is not your own personal programming language tutor though. If we just gave you code to turn in, what would you learn from that?

Just try first.

commented: nicely put :) +5
``````#include <iostream>
using namespace std;

int main()
{
double a,b,c,d,x,y,f;

cout<<"a =";
cin>>a;

cout<<"b =";
cin>>b;

cout<<"c =";
cin>>c;

cout<<"d =";
cin>>d;
if (a>100 || b>100 || c>100 || d>100 || a<-100 || b<-100 || c<-100 || d<-100)
{
cout << "The entered numbers must be in a range from -100 thru 100 ";
}``````

Now please tell me what to do

Oh wow, talk about lazy... you didn't even attempt to solve the actual problem... you just wrote some simple output and an IF statement. And the assignment called for floating point numbers, not doubles...
If you aren't will to make a serious attempt at the program yourself, nobody here is going to so much as reply to your thread, except perhaps to tell you to do it yourself.

<scoff> Good day, sir...

>And the assignment called for floating point numbers, not doubles...
Doubles are floating-point numbers. `float` is single precision and `double` is double precision. Otherwise I agree with your post. :)

i am a beginner programmer. i don't know much.
i know this code only please can any one help me to solve all problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.