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 / a.eklare7

int fifth_element_last(node *head)
{
node *p;
int len=0;
p=head;
while(p->next!=NULL)
{
p=p->next;
len++;
}
p=head;
for(int i=1;i<=len-4;i++)
p=p->next;
return(p->data);
}

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between fread and fwrite function?

1035


Explain what is wrong in this statement?

1070


What is abstract data structure in c?

979


how to make a scientific calculater ?

2012


How can I recover the file name given an open stream or file descriptor?

1033


What is unsigned int in c?

934


Difference between MAC vs. IP Addressing

1100


Which type of language is c?

1025


What is the best style for code layout in c?

1052


Can we access array using pointer in c language?

1044


Are negative numbers true in c?

1003


What is #define used for in c?

1018


How would you obtain the current time and difference between two times?

1238


Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)

979


Is c programming hard?

973