0
#include <cs50.h>
#include<math.h>
int main(void)
{
    int n = 0;
    do
    {
        n = (get_float("Change owed: ") * 100);
    }
    while (n < 0);
    int q = ((n / 25) %)
            int d = ((q / 10) %)
                    int r = ((d / 5) %)
                            int c = (n %)
                                    int i = q + d + n + c
                                            printf("%i");
}

In the slides, I leaned "%" meant remainder in C math. Unfortunately, it seems like I may have used % incorrectly or something else is wrong. Please help!

I have some screenshots regarding this, a la below.

ErrorHelp50

Could anyone tell me how to fix this? I KNOW the forum idol Cliff B would be (a bit) unhappy with this, but I am utterly lost. Please help me! I have (re)watched the lectures and reviewed the slides. I would appreciate your help! It would be appreciated!

3
  • you missed some semi-colons after these statements.
    – stensal
    Commented May 28, 2020 at 2:28
  • I don't think you need to initialise 'n' as '0' when you redefine it in the next line of code anyway. int n; should do the same thing.
    – RuddyDev
    Commented May 29, 2020 at 4:57
  • I do, otherwise, the compiler will start screaming at me. Commented May 29, 2020 at 5:04

1 Answer 1

1
#include <cs50.h>
#include <math.h>
int main(void) {
  int n = 0;
  do {
    n = (get_float("Change owed: ") * 100);
  } while (n < 0);

  int q = ((n / 25) % 10);  //<- need semicolon to terminate each statement
  int d = ((q / 10) % 10);
  int r = ((d / 5) % 10);
  int c = (n % 10);
  int i = q + d + n + c;
  printf("%i", i);  // <- need to provide a variable to print out. 
}

You must log in to answer this question.

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