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 / amol b

int return_fifth_from_end()
{
int a[5],curr_ct=0;
struct node *p;
p=head;
while(p->next!=NULL)
{
a[curr_ct%5]=p->val;
p=p->next;
curr_ct++;
}
if(curr_ct>=5)
return a[(curr_ct-5)%5];
else
return -1;
}

Is This Answer Correct ?    8 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why does the call char scanf work?

1154


What is nested structure?

997


Can you write the function prototype, definition and mention the other requirements.

1085


What is a good data structure to use for storing lines of text?

1033


#define MAX(x,y) (x) >(y)?(x):(y) main() { inti=10,j=5,k=0; k= MAX(i++,++j); printf("%d..%d..%d",i,j,k); }

1109


What is abstract data structure in c?

976


What is the correct code to have following output in c using nested for loop?

1028


Explain #pragma statements.

979


Add Two Numbers Without Using the Addition Operator

769


Explain how do you search data in a data file using random access method?

1070


Write a program to show the change in position of a cursor using c

997


In the DOS enveronment, normal RAM that resides beyond the 1mb mark. a) expanded memory b) swapped memory c) Extended memory d) none

1159


Explain how are portions of a program disabled in demo versions?

1074


Why is C language being considered a middle level language?

1043


Explain modulus operator. What are the restrictions of a modulus operator?

970