in Programming in C
306 views
0 votes
0 votes
int main();

{

int a,*b,**c,***d,****e;

a=10;

b=&a;

c=&b;

d=&c;

e=&d;

print f(“a=%d b=%u c=%u d=%u e=%u e=%u\n”, a,b,c,d,e);

print f(“ %d %d %d \n”,a,a+*b,**c+***d+,****e);

return 0;

}
in Programming in C
306 views

1 Answer

2 votes
2 votes
/*there are some errors in program */

int main(); // there should not be semicolon after main()

{

int a,*b,**c,***d,****e;

a=10;

b=&a;

c=&b;

d=&c;

e=&d; // there should not be space between print and f

print f(“a=%d b=%u c=%u d=%u e=%u e=%u\n”, a,b,c,d,e); //an extra e=%u

print f(“ %d %d %d \n”,a,a+*b,**c+***d+,****e); //3 %d and 4 values to print, + is an unary operator so its format is like a+b.

return 0;

}

after correcting the errors the code becomes

int main()

{

int a,*b,**c,***d,****e;

a=10;

b=&a;

c=&b;

d=&c;

e=&d;

printf("a=%d b=%u c=%u d=%u e=%u \n", a,b,c,d,e);

printf(" %d %d %d %d\n",a,a+*b,**c+***d,****e);

return 0;

}

this will print

a=10 b= 0xf...(address of a) c=0xf....(address of b) d=0xf....(address of c) e=0xf....(address of d)

10 20 20 10

Related questions