Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Write a program to swap two numbers without using the third variable?

1060


Why is c used in embedded systems?

1111


How can I pad a string to a known length?

1031


what is uses of .net

1728


What is string function c?

1013


What is difference between arrays and pointers?

1060


What are variables c?

1043


What is the use of linkage in c language?

1053


Why isn't it being handled properly?

1061


What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?

1068


What is signed and unsigned?

1056


can any one provide me the notes of data structure for ignou cs-62 paper

2169


What is a const pointer?

1105


Explain what is wrong with this statement? Myname = ?robin?;

1562


How do I create a directory? How do I remove a directory (and its contents)?

1163