Please explain why the answer is what is is thoroughly. I am trying to study for
ID: 3827648 • Letter: P
Question
Please explain why the answer is what is is thoroughly. I am trying to study for my test. I will make sure to thumbs up! thank you very much for your time
13. Consider two functions square 1 and square 2 given below: int square 1 int num) num num num return num; void square 2 (int num num num num int main int number 7; square 1 (number) printf The value of number is sd n", number) square 2 number); printf The value of number is SdAn number n", return 0; What will be the output when this program is run? a) The value of the number is 49 The value of the number is 2401 b) The value of the number is 7 The value of the number is 49 c) The value of the number is 49 The value of the number is 49 d) The value of the number is 7 The value of the number is 7 Answer D 14. Suppose you have just opened the file test.txt and execute the statements shown below: char buffer [12 fscanf (pFile, "Ss", buffer printf s", buffer File test.txt consists of a single line of text The quick brown fox jumped over the lazy dog's back. What will be the output from the printf? a) The quick br b) The quick brown fox jumped over the lazy dog's back. c) The quick b d) The e) None of the above. AnswerExplanation / Answer
13) Ans) b
Reason:
square_1(number) here we are passing the value of the variable as argument to the function while calling it.
So even if we performed any operations on this variable in the function square_1() then there is no change in the value of the variable in the main() function.
That why when we prints printf("The vaalue of number %d",number); this will display the number '7'
But here square_2(&number); to this function we are passing the reference as argument while calling the function.So if we performed any operation on the value of the variable it reflects in the number variable which is in the main() method after returning the control from the function_2().
So *number=(*number)*(*number); This will make *number =7 * 7;
*number=49;
so when we call printf("The vaalue of number %d",number); this will prints 49
_________________
14)Ans) d (The)
As we are using %s it just reads only one word (which is starting word.)But to read the whole sentence we have to user %[^ ] So that it will read the whole sentence.But as we used %s the output is " The "
__________Thabk You