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 / abhijit annaldas

node* getNthFromLast(node* head, int n)
{
int c;
node *nth;
while(pt!=NULL)
{
pt=pt->next;
c++;
if(c>=n)
*nth=pt;
}
if(c<n) //LL contains less than n nodes
return (*node)0;
else
return *nth;
}

Use it as..
fifth_node = getNthFromLast(head, 5);

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

differentiate built-in functions and user – defined functions.

1098


What are header files in c programming?

1141


What is && in c programming?

1173


Explain how can I manipulate strings of multibyte characters?

1208


write a program fibonacci series and palindrome program in c

1052


Why c language is called c?

1024


#define PRINT(int) printf("int = %d ",int) main() {< BR> intx,y,z; x=03;y=02;z=01; PRINT(x^x); z<<=3;PRINT(x); y>>=3;PRINT(y); }

1189


Tell me when would you use a pointer to a function?

1070


An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above

1171


How do you determine a file’s attributes?

1090


What is the main difference between calloc () and malloc ()?

1163


a value that does not change during program execution a) variabe b) argument c) parameter d) none

1244


Is javascript based on c?

1075


hi to every one .. how to view table pool after creating the pooled table? plz help me.. if any knows abt this ..

1925


Explain what is #line used for?

1075