Implement a function that returns the 5th element from the
end in a singly linked list of integers in one pass.
Answer Posted / gbohrn
int return_fifth_from_end()
{
int i,j;
struct node *p,*q;
*p=HEAD_NODE;
for(i=0;i<4;i++)//will make p point to the 5th element
{
p=p->next;
if(p==NULL)
{
printf("List has less than 5 elements");
}
}
q=HEAD_NODE;
while(p->next!=NULL)
{
p=p->next;
q=q->next;
}
return(q->Value);
}
Is This Answer Correct ? | 5 Yes | 6 No |
Post New Answer View All Answers
Write a function that will take in a phone number and output all possible alphabetical combinations
What is the c language function prototype?
Explain what is the benefit of using an enum rather than a #define constant?
why programs in c are running with out #include
Explain what math functions are available for integers? For floating point?
main() { struct s1 { char *str; struct s1 *ptr; }; static struct s1 arr[] = { {"Hyderabad",arr+1}, {"Bangalore",arr+2}, {"Delhi",arr} }; struct s1 *p[3]; int i; < BR> for(i=0;i<=2;i++) p[i] = arr[i].ptr; printf("%s ",(*p)->str); printf("%s ",(++*p)->str); printf("%s ",((*p)++)->str); }
Do character constants represent numerical values?
What is build process in c?
What are the advantages and disadvantages of c language?
plz let me know how to become a telecom protocol tester. thank you.
What are linked lists in c?
What is the use of pragma in embedded c?
Describe the difference between = and == symbols in c programming?
What is extern c used for?
hi any body pls give me company name interview conduct "c" language only