• Skip to main content
  • Skip to footer

CS50's Introduction to Computer Science on Edx: Supplementary resource

CS50 threads to aide as a supplementary resource

Understanding define function with Scrabble lab

CS50 threads to aide as a supplementary resource › Forums › CS50’s Introduction to Computer Science by Harvard University on Edx › Week 2 › Understanding define function with Scrabble lab

Tagged: const, define function, scrabble lab problem

  • This topic is empty.
Log In Register Lost Password
Viewing 1 post (of 1 total)
  • Author
    Posts
  • November 14, 2021 at 7:09 am #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:


      Copy Code
      Copied
      Use a different Browser

      
      
      #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:


      Copy Code
      Copied
      Use a different Browser

      
      
      #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]

    • Author
      Posts
    Log In Register Lost Password
    Viewing 1 post (of 1 total)
    • You must be logged in to reply to this topic.
    Log In

    Log in / Register

    Initiative by Digital Splendid OPC Pvt. Ltd.