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
What are the different file extensions involved when programming in C?
what is different between auto and local static? why should we use local static?
What type is sizeof?
What is s or c?
What is difference between arrays and pointers?
Calculate the weighted average of a list of n numbers using the formula xavg = f1x1+f2x2+ ….+ fnxn where the f’s are fractional weighting factors, i.e., 0<=fi<1, and f1+f2+….+fn = 1
What is huge pointer in c?
How do you use a pointer to a function?
Write a program to display all the prime nos from 1 to 1000000, your code should not take time more than a minute to display all the nos.
A collection of data with a given structure for excepting storing and providing on demand data for multiple users a) linked list b) datastructer c) database d) preprocessor
What is a string?
What are the advantages of c language?
disply the following menu 1.Disply 2.Copy 3.Append; as per the menu do the file operations 4.Exit
What are global variables?
What is the difference between #include