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 / manesh nambiar

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!=NULL)
{
p=p->next;
q=q->next;
}
return(q->Value);
}

Is This Answer Correct ?    8 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Whats s or c mean?

1028


`write a program to display the recomended action depends on a color of trafic light using nested if statments

2135


In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?

1232


Why do we use & in c?

1006


What is the difference between volatile and const volatile?

990


Function calling procedures? and their differences? Why should one go for Call by Reference?

1086


What are the properties of union in c?

1055


What are local variables c?

1025


What is the incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?

1473


What is a structure in c language. how to initialise a structure in c?

1067


What is the acronym for ansi?

1051


Explain about the constants which help in debugging?

1379


What is the difference between %d and %i?

1100


Write a code to generate divisors of an integer?

1071


What would be an example of a structure analogous to structure c?

1001