- This topic has 0 replies, 1 voice, and was last updated 3 years, 3 months ago by .
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.
aiannum.com has rebranded as Progaiz.com
› Forums › CS50’s Introduction to Computer Science by Harvard University on Edx › Week 2: [Arrays] – Functions, Variable and Scope, Debugging, Arrays, and Command Line Arguments › Seeking an explanation how function argument works
Tagged: scrabble lab problem
[dm_code_snippet background=”yes” background-mobile=”no” slim=”yes” line-numbers=”yes” bg-color=”#abb8c3″ theme=”dark” language=”clike” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
int compute_score(string word); string find_winner(int score1, int score2);
[/dm_code_snippet]
With compute_score, there will be two words used, word1 and word2. Instead of
[dm_code_snippet background=”no” background-mobile=”yes” slim=”yes” line-numbers=”yes” bg-color=”#abb8c3″ theme=”dark” language=”clike” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
int compute_score(string word1,string word2);
[/dm_code_snippet]
It is
[dm_code_snippet background=”yes” background-mobile=”no” slim=”yes” line-numbers=”yes” bg-color=”#abb8c3″ theme=”dark” language=”clike” wrapped=”yes” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]
int compute_score(string word);
[/dm_code_snippet]
This is unlike score1, score2 with find_winner. Is it due to get_string function to be used for getting input?
What is confusing is that while word argument with compute_score will subsequently change to word1 and word2, the arguments with find_winner (score1, and score2) are mentioned exactly the way they will be later used.
Reply
https://edstem.org/us/courses/176/discussion/1791039?answer=4108983[learn_press_profile]
