Implement a function that returns the 5th element from the
end in a singly linked list of integers in one pass.
Answer Posted / amol b
int return_fifth_from_end()
{
int a[5],curr_ct=0;
struct node *p;
p=head;
while(p->next!=NULL)
{
a[curr_ct%5]=p->val;
p=p->next;
curr_ct++;
}
if(curr_ct>=5)
return a[(curr_ct-5)%5];
else
return -1;
}
| Is This Answer Correct ? | 8 Yes | 0 No |
Post New Answer View All Answers
Where in memory are my variables stored?
What is the difference between c &c++?
how do you programme Carrier Sense Multiple Access
Tell me about low level programming languages.
Is null equal to 0 in sql?
Why c is a mother language?
write a C program: To search a file any word which starts with ?a?. If the word following this ?a? starts with a vowel.Then replace this ?a? with ?a? with ?an?. redirect with the output onto an output file.The source file and destination file are specified by the user int the command line.
What is the explanation for modular programming?
Why does notstrcat(string, "!");Work?
What are dangling pointers? How are dangling pointers different from memory leaks?
What is the meaning of ?
Is the exit() function same as the return statement? Explain.
how to capitalise first letter of each word in a given string?
How many types of arrays are there in c?
Write a program that takes a 5 digit number and calculates 2 power that number and prints it(should not use big integers and exponential functions)