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
Explain the difference between null pointer and void pointer.
How can my program discover the complete pathname to the executable from which it was invoked?
Is it possible to pass an entire structure to functions?
What is far pointer in c?
What is anagram in c?
Write a program for Overriding.
Should a function contain a return statement if it does not return a value?
what is the difference between class and unio?
What is the symbol indicated the c-preprocessor?
Can we declare variable anywhere in c?
A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream
Explain the difference between ++u and u++?
What is the difference between exit() and _exit() function in c?
swap 2 numbers without using third variable?
how do you execute a c program in unix.