Implement a function that returns the 5th element from the
end in a singly linked list of integers in one pass.

Answer Posted / tarun dhiraj

Consider:
struct Node
{
int data;
struct Node *next;
}*start;

void FIFTHFRMLAST()
{
struct Node *ptr;
ptr=start;

printf("\n");

/*Traverse elements of linked list till the 5th element from
the end of linked list*/
while(ptr->next->next->next->next->next!=NULL)
{
ptr=ptr->next;
}
printf("->%d",ptr->data);

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;

2008


Wt are the Buses in C Language

2753


What is int main () in c?

627


What will the preprocessor do for a program?

593


what is stack , heap ,code segment,and data segment

2224






What functions are used in dynamic memory allocation in c?

597


Is c call by value?

607


What is merge sort in c?

647


What are the different types of linkage exist in c?

614


define string ?

669


What are different types of variables in c?

571


What is the difference between printf and scanf in c?

752


What is the difference between ā€˜gā€™ and ā€œgā€ in C?

2575


What is sizeof array in c?

596


How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?

583