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
Difference between Function to pointer and pointer to function
Is c is a middle level language?
What does return 1 means in c?
Why is c called "mother" language?
Explain what is meant by high-order and low-order bytes?
What is the purpose of main() function?
What is the use of c language in real life?
write a program to find the given number is prime or not
c language supports bitwise operations, why a) 'c' language is system oriented b) 'c' language is problem oriented c) 'c' language is middle level language d) all the above
What do you mean by dynamic memory allocation in c? What functions are used?
Is there any data type in c with variable size?
What is the use of f in c?
What is the difference between fread and fwrite function?
What are nested functions in c?
Subtract Two Number Without Using Subtraction Operator