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

      I fail to understand define command while taking a look at template code provided that does not have mention of define command. Since there is no TODO after #include, I guess define command is not needed or at least not mandatory.

      A similar problem with input of months has define command:

      
      
      #include <stdio.h>
      #define MONTHS 12
      int main(void)
      {
      int days[MONTHS] = {31,28,31,30,31,30,31,31,30,31,30,31};
      int index;
      for (index = 0; index < MONTHS; index++)
      printf("Month %d has %2d days.\n", index +1,
      days[index]);
      return 0;
      }

       

      Is it desirable to mention define with POINTS? Or it is wrong for this problem:

      
      
      #include <stdio.h>
      #include <cs50.h>
      #include <ctype.h>
      #include <string.h>
      #define POINTS 26
      
      // Points assigned to each letter of the alphabet
      int POINTS[] = {1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 1, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10};
      
      int compute_score(string word);


      Reply


      https://edstem.org/us/courses/176/discussion/842067?answer=1929475[learn_press_profile]

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