Select the correct answerOutput by the below given code is:#include<stdio.h>int Function(int x, int *P1, int **P2) { int y, z; **P2 += 2; z = **P2; *P1 += 3; y = *P1; x += 4; return x + y + z; } int main() { int c, *b, **a; c = 10; b = &c; a = &b; printf("%d ", Function(c, b, a)); return 0;}Options40414344
Question
Select the correct answerOutput by the below given code is:#include<stdio.h>int Function(int x, int *P1, int **P2) { int y, z; **P2 += 2; z = **P2; *P1 += 3; y = *P1; x += 4; return x + y + z; } int main() { int c, *b, **a; c = 10; b = &c; a = &b; printf("%d ", Function(c, b, a)); return 0;}Options40414344
Solution
The correct answer is 44.
Here's the step-by-step explanation:
-
The initial value of
cis 10.bis a pointer toc, andais a pointer to the pointerb. -
The function
Functionis called withc,b, andaas arguments. Inside the function,xisc(10),P1isb(&c), andP2isa(&b). -
**P2 += 2;This line adds 2 to the value pointed byP2(which isc). So,cbecomes 12. -
z = **P2;Now,zis assigned the value ofcwhich is 12. -
*P1 += 3;This line adds 3 to the value pointed byP1(which isc). So,cbecomes 15. -
y = *P1;Now,yis assigned the value ofcwhich is 15. -
x += 4;This line adds 4 tox. So,xbecomes 14. -
return x + y + z;This line returns the sum ofx,y, andzwhich is 14 + 15 + 15 = 44.
So, the output of the program is 44.
Similar Questions
Select the correct answerThe values of the attribute should be present in ________.
You need to code your program using the appropriate programming language before creating the logic.Group of answer choicesTrueFalse
Select the correct answerWhat will be the output of the following Python code?>>>ct1="codetantra">>>ct1[:3]>>>Optionsdecododetacodetantra
Code :Scanner sc = new Scanner(System.in);String str = sc.next();Match the options correctly.float f =Answer 1boolean flag = Answer 2int x =Answer 3char c = Answer 4
Select the correct answerWhich of the following is an invalid variable?Optionscode_tantra_1code_1code_tantra
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.