849 views
0 votes
0 votes

Assume that p & q are pointers. What will be the output after performing following sets of operations on a given linked list?

Struct node {

char info;

struct node *link;

};

Operations are:

q = p → link → link ;

q → link → link = p → link;

printf (“%c”,  q → link → link → link → info);


the given ans is b but I am getting c.. can anyone plz verify?

1 Answer

Best answer
1 votes
1 votes

q = p → link → link 

means q is pointing to node $b$

q → link → link = p → link

means node $c$ is now pointing to node $a$

q → link → link → link → info

| b | link | → | c | link | →| a | info | → $b$

$so$ $answer$ $ is $ $b$

selected by

Related questions

0 votes
0 votes
1 answer
1
0 votes
0 votes
1 answer
3
0 votes
0 votes
0 answers
4