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
Find the second largest element in an array with minimum no of comparisons and give the minimum no of comparisons needed on an array of size N to do the same.
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.
Is there a built-in function in C that can be used for sorting data?
Why do we use null pointer?
What are the salient features of c languages?
What are the 32 keywords in c?
where are auto variables stored? What are the characteristics of an auto variable?
how could explain about job profile
Multiply an Integer Number by 2 Without Using Multiplication Operator
What does the file stdio.h contain?
Are the expressions * ptr ++ and ++ * ptr same?
How can I list all of the predefined identifiers?
explain what are actual arguments?
provide an example of the Group by clause, when would you use this clause
The program will first compute the tax you owe based on your income. User is prompted to enter income. Program will compute the total amount of tax owed based on the following: Income Tax 0 - $45,000 = 0.15 x income $45,001 - $90,000 = 6750 + 0.20 x (income – 45000) $90,001 - $140,000 = 15750 + 0.26 x (income – 90000) $140,001 - $200,000 = 28750 + 0.29 x (income – 140000) Greater than $200,000 = 46150 + 0.33 x (income – 200000) Dollar amounts should be in dollars and cents (float point numbers with two decimals shown). Tax is displayed on the screen.