## Question 1 What is the output if the following string is given as input? $s$ = "$25$ you Rock" ### Options 1. "$25$" Incorrect ---------------------------- 2. $20$ Incorrect ---------------------------- 3. "$25$ you rock" Incorrect ---------------------------- 4. $25$ Correct The string to integer conversion of "$25$ you rock" is $25$. ---------------------------- --------------------------------------------- ## Question 2 What is the output if the following string is given as input? $s$ = "$\: \: \:$ -$54$-$4$ $\: \: \:$" ### Options 1. $54$ Incorrect ---------------------------- 2. -$54$ Correct The string to integer conversion of "$\: \: \:$ -$54$-$4$ $\: \: \:$" is -$54$. Since we encounter a non-digit character, `-`, after `4`, we stop processing further and return the integer equivalent to "-$54$". ---------------------------- 3. -$58$ Incorrect ---------------------------- 4. -$50$ Incorrect ---------------------------- --------------------------------------------- ## Question 3 What is the output if the following string is given as input? $s$ = "$12 \: \:34 \: \:56 \: \:78$" ### Options 1. $12345678$ Incorrect ---------------------------- 2. "$12 \: \:34 \: \:56 \: \:78$" Incorrect ---------------------------- 3. $12$ Correct The string to integer conversion of "$12 \: \:34 \: \:56 \: \:78$" is $12$. Since we encounter a non-digit character, a whitespace `' '`, after $12$, we stop here and return its equivalent integer. ---------------------------- 4. $78$ Incorrect ---------------------------- --------------------------------------------- ## Question 4 What is the output if the following string is given as input? $s$ = "$87.5$" ### Options 1. $87$ Correct The string to integer conversion of "$87.5$" is $87$. Since we encounter a non-digit character, `.`, after $87$, we stop here and return its equivalent integer. ---------------------------- 2. $87.5$ Incorrect ---------------------------- 3. $88$ Incorrect ---------------------------- 4. "$87.5$" Incorrect ---------------------------- --------------------------------------------- ## Question 5 What is the output if the following string is given as input? $s$ = "-$00035$" ### Options 1. -$00035$ Incorrect ---------------------------- 2. "-$00035$" Incorrect ---------------------------- 3. -$35$ Correct The string to integer conversion of "$-00035$" is $-35$. ---------------------------- 4. $35$ Incorrect ---------------------------- --------------------------------------------- ## Question 6 What is the output if the following string is given as input? $s$ = "$33 \: \:$ Thirteen $\: \:56 \: \:78$" ### Options 1. $33$ Correct The string to integer conversion of "$33 \: \:$ Thirteen $\: \:56 \: \:78$" is $12$. Since we encounter a non-digit character, `T`, after $33$, we stop here and return its equivalent integer. ---------------------------- 2. "$33 \:\:13\:\: 56\:\: 78$" Incorrect ---------------------------- 3. $335678$ Incorrect ---------------------------- 4. "$33$" Incorrect ---------------------------- --------------------------------------------- ## Question 7 What is the output if the following string is given as input? $s$ = "$\: \:$-Minus$71$" ### Options 1. $71$ Incorrect ---------------------------- 2. -$71$ Incorrect ---------------------------- 3. "-$71$" Incorrect ---------------------------- 4. $0$ Correct The string to integer conversion of "$\: \:$-Minus$71$" is $0$. Since we encounter a non-digit character, `M`, after `-`, we return $0$. ---------------------------- --------------------------------------------- ## Question 8 What is the output if the following string is given as input? $s$ = "King$\:\:\:10$" ### Options 1. "Ten" Incorrect ---------------------------- 2. $10$ Incorrect ---------------------------- 3. $0$ Correct The string to integer conversion of "King$\:\:\:10$" is $0$. Since the first character we encounter is a non-digit character, `K`, we return $0$. ---------------------------- 4. "King$\:\:\:10$" Incorrect ---------------------------- ---------------------------------------------