623 views
0 votes
0 votes

Consider the following structure and declaration :

1. struct date {

2. int day;

3. int month;

4. int year;

5. };

Struct data *pd ;

Which of the following is the correct method to refer to the year member ?

(A) (*pd)⋅year

(B) (*pd)*year

(C) (*pd)→year

(D) pd→year
 

3 Answers

0 votes
0 votes
I think ans will be a & c because in a)  using (*pd) we will get inside reference and (*pd).year direct selector(.) we can access year member of the structure and in c) for (*pd) same as above and (*pd)->year is also indirect selector(->) optional method to represent direct selector(.).
Hope it helps..notify me if there is correction..
0 votes
0 votes

Since it is a pointer to a structure so first we need to de reference it to refer to the variable date and then we need the dot operator to point to the appropriate member.

(*pd) will point to the appropriate variable... Here they have not initialized the pointer to the address of any variable of type struct date. It should have been

struct date d;

struct date *pd =&d;

 

Now (*pd) will refer to the variable and (*pd).year will refer to the year member.

So A is correct. D is also a simplified notion of first option so D is also coorect.

Finally A and D are correct

 

Related questions

0 votes
0 votes
0 answers
1
sh!va asked Mar 14, 2017
1,280 views
Consider the following logic families :1. MOS 2. DTL 3. RTL 4. ECLThe sequence of the logic families in the order of their increasing noise margin is(A) 3, 4, 1, 2(B) 3, ...
0 votes
0 votes
1 answer
2
sh!va asked Mar 14, 2017
506 views
In a communication system, noise is most likely to affect the signal(A) at a transmitter(B) in a channel(C) in the information source(D) at the destination
0 votes
0 votes
1 answer
4
sh!va asked Mar 14, 2017
367 views
The highest data rate can be transmitted using following cables :1. Co-axial cable2. Twisted-wire cable3. Optical fiber cableThe correct sequence in the increasing order ...