Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given this code block, which of the following are true? ChooseALLthatapply reply

ID: 3791153 • Letter: G

Question

Given this code block, which of the following are true? ChooseALLthatapply reply input ("Ready to do another? Y(es) or N(o) s'); if reply 'Y' I I reply 'y' disp ('Great! else disp okay see you later. Great displays whenever the user replies with either YorY "Okay-see you later' displays whenever the user replies with either Nor n' whenever the user replies with any SINGLE CHARACTER than my,Nm. Do message displays, other ti Whenever the user replies with any SINGLECHARACTER other than myNm. okay-see you later displays. QUESTION 7 Given this code block, which of the following is true? clc. nuna, 5; if num disp Weird but true! else disp ('Nope') oAThe IF statement can only work with expressions that resolve (simplit)toTRUE and FALSE. o B. In this context, the value 5 is being interpreted as TRUE This code does not work D. Both A and B are true. QUESTION 8 In an IF statement, the condton must explicitly include a relational operator 0 e, num 5; if num disp ('Weird but true! else disp ('Nope') end

Explanation / Answer

So, here are the answers:

(6).

The code snippet means that if user inputs either 'Y' or 'y', then it will print 'Great !' otherwise it will display "Okay - see you later." It will not check for any other specific input like 'N' or 'n' it will just execute the else part.

So, the options you checked are true.

Firstly, it will print "Great" for 'y" or 'y'. When user enters 'N' or 'n', it displays "Okay " ..... message. So 2nd option is also true.

If there was an option like when user replies with any SINGLE CHARACTER other than 'Y' or 'y' , "Okay"... message is printed; then this would be the perfect option. But it is different in option 3 and 4. So, 1 and 2 are correct answers.

(7)

If you will run this code in MATLAB, it will print "weird but true". This means that number is considered and allowed in the input.

Here, the output will get generated but there is not any expression that is evaluated inside if condition. So, you can't goo with option A.

Option C is not possible as the code will run fine.

So, the right answer should be option B.

Now comes option D. But, A is not true as here, num is written there which is not an expression because the expression generally includes operators and operands both. If we consider such, option A is not true. So, the answer should be

B. In this context, the value 5 is being interpreted as TRUE.

(8)

The code snippet is the same as question 7. So it is observed in (7) that the condition becomes true.

But, the question says that an if condition statement must include a relational operator, this turns out to be false because here, no operator is used and although the code will be running successfuliy.

So the answer is (b) FALSE.

Do comment if there is any query. Thank you. :)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote