Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Write a program to find all the possible values of x & y which satisfy the following equation 12.9995 <2x+3y<13.00049.

0 votes
asked Oct 31, 2018 by anonymous
what is the wrong in the following code

#include <stdio.h>

main()

{

 float a, b,x,y, amount;

a=2.000;

b=3.000;

amount=a*x+b*y;

 for(x = 1.555;x<=2.001;x=x+0.001)

{

for(y=3.001;y<=4.001;y=y+0.001)

      {

            if(amount > 12.9995 && amount<13.00049)

{

      printf("\n Rate is: x = %f, y=%f ",x,y);

break;

}

    }

}

}

1 Answer

0 votes
answered Nov 3, 2018 by JEANMARC (180 points)
#include <stdio.h>

int main()

{

    float a = 2, b = 3;
    float x, y, amount;

    for(x = 1.555; x <= 2.001; x = x + 0.001) {
        for(y = 3.001; y <= 4.001; y = y + 0.001){
            amount = (a * x) + (b * y);
            
            if(amount > 12.9995 && amount < 13.00049)
                printf("\n Rate is: x = %f, y = %f ", x, y);
        }
    }
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...