Implement a function that returns the 5th element from the
end in a singly linked list of integers in one pass.
Answer Posted / manesh nambiar
int return_fifth_from_end()
{
int i,j;
struct node *p,*q;
*p=HEAD_NODE;
for(i=0;i<4;i++)//will make p point to the 5th element
{
p=p->next;
if(p==NULL)
{
printf("List has less than 5 elements");
}
}
q=HEAD_NODE;
while(p!=NULL)
{
p=p->next;
q=q->next;
}
return(q->Value);
}
| Is This Answer Correct ? | 8 Yes | 7 No |
Post New Answer View All Answers
What is a dynamic array in c?
What are different types of pointers?
What are the different data types in C?
Differentiate fundamental data types and derived data types in C.
What are the rules for the identifier?
What do you mean by dynamic memory allocation in c?
which type of aspect you want from the student.
Is boolean a datatype in c?
What does c value mean?
What functions are in conio h?
What is sizeof return in c?
what is the different bitween abap and abap-hr?
What is the meaning of typedef struct in c?
What is difference between %d and %i in c?
What is hash table in c?