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

Why clrscr is used in c?

1014


What do you know about the use of bit field?

1042


List the difference between a 'copy constructor' and a 'assignment operator' in C?

1087


Can we declare a function inside a function in c?

1030


What is a const pointer in c?

1126


How can you read a directory in a C program?

1139


What is difference between structure and union with example?

1050


What is clrscr ()?

1106


How many main () function we can have in a project?

1103


Why is sizeof () an operator and not a function?

1025


What is difference between stdio h and conio h?

1367


The file stdio.h, what does it contain?

1154


Explain high-order bytes.

1105


In a switch statement, explain what will happen if a break statement is omitted?

1064


What is indirection? How many levels of pointers can you have?

1124