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
what is the basis for selection of arrays or pointers as data structure in a program
What is the meaning of typedef struct in c?
Do array subscripts always start with zero?
Write a program to check palindrome number in c programming?
What is difference between %d and %i in c?
What does %d do in c?
What is the purpose of macro in C language?
What are derived data types in c?
Explain what are global variables and explain how do you declare them?
1.int a=10; 2.int b=20; 3. //write here 4.b=30; Write code at line 3 so that when the value of b is changed variable a should automatically change with same value as b. 5.
How can I find out how much free space is available on disk?
What is chain pointer in c?
Why doesnt this code work?
hello freinds next week my interview in reliance,nybody has an idea about it intervew questions..so tell
Can a program have two main functions?