• recategorized by
1,599 views

2 Answers

1 1 vote
#include <stdio.h>

int f(int x, int *py, int **ppz) {
	**ppz += 1;
	*py += 2;
	x += 3;
	return x + *py + **ppz;

}

int main() {
	int c = 4;
	int *b = &c;
	int **a = &b;
	printf("%d\n", f(c, b, a));
}

$c$ is passed by value

x is just a local variable of f, it is not same as c,( call by value) while calling the function f, c's value was passed to it, that's it. Any changes to c's ( using its pointer variable) value will not effect x 's value.

$**ppz += 1$ will modify the value of c to 5

$*py += 2$ will modify the value of c to 7

$x = x + 3  = 7$ (local to f )

$x + *py + **ppy = 7 + 7 + 7 = 21$

Position:
Show:

Related questions

4 4 votes
1 1 answer
1.3k
1.3k views
GO Classes asked Apr 30, 2022
1,295 views
#include<stdio.h int test(int *a, int *b) { int c = *a-*b; if (c<0) return 0; else return (1 + test(&c, b)); } void main() { int x = 15; int y = 4; int a = test(&x,&y); p...
0 0 votes
2 2 answers
404
404 views
Shubham Sharma 2 asked Sep 9, 2025
404 views
Consider the following code:#include<stdio.h void f1(char *x, char *y) { char *t1; t 1 = x; x= y; y = t 1;} void f2(char x, char y) { char *t1 ; t1 = *x; *x = *y; *y = ...
4 4 votes
1 answers 1 answer
1.5k
1.5k views
Bikram asked May 14, 2017
1,544 views
Point out the error : #include <stdio.h void f(int*); int main() { int i=35,*z; z=f(&i); printf("%d",z); return 0; } void f(int*m) { return(m+2); }error in function calle...