• 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

Scrabble problem: Uppercase and lowercase letters

CS50 threads to aide as a supplementary resource › Forums › CS50’s Introduction to Computer Science by Harvard University on Edx › Week 2 › Scrabble problem: Uppercase and lowercase letters

Tagged: arrays, ASCII, ASCII codes, builtin functions, c, islower, isupper, library functions, lowercase, lowercase letters, scrabble lab problem, string.h, strlen, toupper, uppercase, uppercase letters

  • This topic is empty.
Log In Register Lost Password
Viewing 1 post (of 1 total)
  • Author
    Posts
  • November 19, 2021 at 7:19 am #56
    admin
    Keymaster

      Working on Week 2, Scrabble Lab 2.


      Copy Code
      Copied
      Use a different Browser

      
      
      int compute_score(string word)
      {
          int n = strlen(word);
          char temp_upper;
          int score = 0;
          for(int i = 0; i< n; i++)
          {
              temp_upper = toupper(word);
              int point_index = temp_upper - 65;
              score = score + POINTS[point_index];
          }
          return score;
      }

       

      Source: https://github.com/volkansahn/CS50-Fall2020/blob/master/Week2/Lab2/scrabble.c

      I know referring blindly to answer might not be acceptable but doing so for the sake of understanding.

      Here are few of the things that I need to make clear:

      1. Is strlen an inbuilt function with used libraries (string.h/ctype.h) that computes length of a string?

      2. temp_upper = toupper(word); Does this command converts all entered letters to uppercase letters?

      3. int point_index = temp_upper – 65; All letters are converted to smallcase letters so that POINTS array can be applied?


      Reply


      https://edstem.org/us/courses/176/discussion/874392?answer=1997454[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.