- This topic is empty.
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.
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 › Printf and return functions synonymous?
Tagged: c, data type, printf, return, return value, returning values, scrabble lab problem, value returned by function
[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”]
string find_winner(int score1, int score2) { if (score1 > score2) { return "Player 1 wins!"; } else if (score2 > score1) { return "Player 2 wins!"; } else { return "Tie!"; }
[/dm_code_snippet]
Using printf:
[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”]
if (score1 > score2) { printf ("player1 winner"); } if (score2 > score1) { printf ("player2 winner"); } else { printf ("tie"); }
[/dm_code_snippet]
Are return and printf functions synonymous?
Reply
https://edstem.org/us/courses/176/discussion/933883?answer=2123080[learn_press_profile]