321 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;

}

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

2 votes
2 votes
1 answer
1
0 votes
0 votes
1 answer
2
Nishi Agarwal asked Mar 10, 2019
614 views
void f(int x,int &y,const int &z){x+=z; y+=z;}int main(){ int a=22,b=33,c=44; f(a,b,c); f(2*a-3,b,c); printf("a=%d b=%d c=%d",a,b,c); return 0;}
0 votes
0 votes
0 answers
3
aimhigh asked Jan 8, 2019
1,260 views
#include<stdio.h>void main(){int p=-8;int i= (p++,++p);printf("%d\n",i);}
0 votes
0 votes
1 answer
4
Mak Indus asked Oct 14, 2018
566 views
#include<stdio.h>void swap (char *x, char *y){ char *t = x; x = y; y = t;}int main(){ char *x = "raghav"; char *y = "ravi"; char *t; swap(x, y); printf("(%s...