0
#include <cs50.h>
#include <stdio.h>
#include <math.h>

int main(void)
{
float y;
do
{
     y = get_float("Change: ");
    }  
     while (y < 0);
  printf("%f\n", y * 100);

    float a; float b; float c; float d;
    a = 0.25;
    b = 0.10;
    c = 0.05;
    d = 0.01;
    {
       if (a < y)
      printf("%f\n", y - a);

        if (y < a & y >= b)
      printf("%f\n", y - b);

       if (y < b & y >= c & y < a)
      printf("%f\n", y - c);

        if (y < c & y >= d & y < b)
      printf("%f\n", y - d);
    }       

   // float input(void);
do 
{
(float y - a);
(y - b);
(y - c);
(y - d);
   }
 while (y <= 0);
   printf("done\n");

}

**CAN SOMEONE PLEASE TELL WHAT IS WRONG WITH THIS SYNTAX. I WANT IT TO SUBTRACT Y WITH THE LARGEST NO UNTIL Y = 0. THANKS IN ADVANCE.

0
0

The operator & is one at the bit level, I suppose what you want is the conditional operator AND, which in c corresponds to &&. When we use several conditional operations maybe we should use brackets:

if ((y < a) && (y >= b))
8
  • but this doesnt subtract y until 0 it only does it one time
    – user23682
    Jun 9 '19 at 14:35
  • The truth is that your code does not compile and is riddled with errors, shaded variables, unused variables, rounding errors ...
    – MARS
    Jun 9 '19 at 14:59
  • There is no variable to store and * 100, what does a subtraction and -a, for example, inside a loop? What is the purpose of that while loop? If you want to decrease and do not do it, you simply do several subtractions that do nothing. Honestly your code does not work, I would reconsider thinking about something new. With a certain experience in programming, when I'm faced with a new problem, I almost never write a program directly, before I have to spend hours, even days writing with pencil and paper an algorithm that I think can work
    – MARS
    Jun 9 '19 at 15:15
  • the subtractions are not inside the while loop
    – user23682
    Jun 10 '19 at 6:17
  • can u ps help with the syntax
    – user23682
    Jun 10 '19 at 6:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .