IT, Programming, & Web Development › 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
- This topic is empty.
-
AuthorPosts
-
September 20, 2022 at 9:46 am #599
[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]
-
AuthorPosts
- You must be logged in to reply to this topic.