Ad

Chapter - 11: Structures

Match the following with reference to the following program segment:


Ad
C
Sections
5
Exercises
struct
{
	int x, y;
}s[] = { 10, 20, 15, 25, 8, 75, 6, 2 };
int *i;
i = s;
1.  *(i+3)                      a.  85
2.  s[i[7]].x                   b.  2
3.  s[(s+2)->y/3[i]].y          c.  6
4.  i[i[1]-i[2]]                d.  7
5.  i[s[3].y]                   e.  16
6.  (s+1)->x + 5                f.  15
7.  *(1+i)**(i+4)/*i            g.  25
8.  s[i[0]-i[4]].y+10           h.  8
9.  (*(s+*(i+1)/*i)).x + 2      i.  1
10. ++i[i[6]]                   j.  100
                                k.  10
                                l.  20

Ans:
1.  =  g. 25

 

2.  =  h. 8
i[7] = 2, s[7] = x=8/y=75,
so s[7].x = 8 

3.  =  b. 2
3[i] = i[3] = 15,
(s+2)->y = 75,
75/15 = 3,
s[3].y = 2

4.  =  a. 75
i[1] = 20, 1[2] = 15,
20-15 = 5,
i[5] = 75

5.  =  f. 15
s[3] = 2
i[2] = 15

6.  =  l. 20

7.  =  e. 16
*(1+i) = 20,
*(i+4) = 8,
*i = 10,
20*8/10 = 16

8.  =  a. 85
i[0] = 10, i[4] = 8
s[10-8].y = 75,
75+10 = 85

9.  =  k. 10
*(i+1) = 20, *i = 10,
s+(20/2) = x=8/y=75,
*(s+2).x = 8,
8+2 = 10

10. =  d. 7
i[6] = 6,
++6 = 7

Ad

© 2024 Garbage Valuegarbage value logo