Implement a function that returns the 5th element from the
end in a singly linked list of integers in one pass.
Answer Posted / a.eklare7
int fifth_element_last(node *head)
{
node *p;
int len=0;
p=head;
while(p->next!=NULL)
{
p=p->next;
len++;
}
p=head;
for(int i=1;i<=len-4;i++)
p=p->next;
return(p->data);
}
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
Is r written in c?
What is actual argument?
Why is structure padding done in c?
What is function and its example?
Differentiate between a structure and a union.
What is malloc calloc and realloc in c?
What should malloc() do? Return a null pointer or a pointer to 0 bytes?
write an algorithm to display a square matrix.
What is #include conio h?
What is the translation phases used in c language?
write a program to copy the string using switch case?
Explain the difference between null pointer and void pointer.
Study the following C program :call_me (myvar)int myvar;{ myvar +- 5; }main(){int myvar;myvar = 3;call_me(myvar);printf("%d ",myvar);What will be printed a) 3 b) 5 c) 8 d) symbol
What is difference between scanf and gets?
Why can’t constant values be used to define an array’s initial size?