• This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #480
    admin
    Keymaster

      d is included as integer type. So why in line 70, d is marked as not defined.

      
      
      #include <stdio.h>
      #include <cs50.h>
      
      int entercents(void);
      int count25(int b);
      int remainingafter25(int b);
      int count10(int b);
      int remainingafter10(int b);
      int count5(int b);
      int remainingafter5(int b);
      int count1(int b);
      
      int main(void)
       {
        int b = entercents();
        printf("result is %i\n", b);
      
        int c25 = count25(b);
        printf("count25 is%i", c25);
      
        int r25 = remainingafter25(b);
        printf("remaining after 25count is %i", r25);
      
        b = r25;
      
        int c10 = count10(b);
        printf("count10 is %i", c10);
      
        int r10 = remainingafter10(b);
        printf("remaining after 10count is %i", r10);
      
        b = r10;
        int c5 = count5(b);
        printf("count5 is %i", c5);
      
        int r5 = remainingafter5(b);
        printf("remaining after 5count is %i", r5);
      
        b = r5;
        int c1 = count1(b);
        printf("count1 is %i", c1);
      
        int totalcoins = c25 + c10 + c5 + c1;
        printf("totalcoins %i", totalcoins);
      
      }
      
      int entercents(void)
      
      {
        do
         {
          int d = get_int("enter cents");
         }
      
        while (d < 0);
        return d;
      }
      
      int count25(int b) 
      {
        int x = b / 25;
        return x;
      }
      
      int remainingafter25(int b) 
      {
        int x = b % 25;
        return x;
      }
      
      int count10(int b)
      {
        int x = b / 10;
        return x;
      }
      
      int remainingafter10(int b)
      {
        int x = b % 10;
        return x;
      }
      
      int count5(int b) 
      {
        int x = b / 5;
        return x;
      }
      
      int remainingafter5(int b) 
      {
        int x = b % 5;
        return x;
      }
      
      int count1(int b) 
      {
        int x = b / 1;
        return x;
      }


      Reply


      https://edstem.org/us/courses/176/discussion/1701132?[learn_press_profile]

    Viewing 1 post (of 1 total)
    • You must be logged in to reply to this topic.
    Scroll to Top