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
Whats s or c mean?
`write a program to display the recomended action depends on a color of trafic light using nested if statments
In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?
Why do we use & in c?
What is the difference between volatile and const volatile?
Function calling procedures? and their differences? Why should one go for Call by Reference?
What are the properties of union in c?
What are local variables c?
What is the incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?
What is a structure in c language. how to initialise a structure in c?
What is the acronym for ansi?
Explain about the constants which help in debugging?
What is the difference between %d and %i?
Write a code to generate divisors of an integer?
What would be an example of a structure analogous to structure c?