Wednesday, July 14, 2010

A c++ program related to linked list..that will accept a no. of int type and add the elements at end of list?

hello everyone..can you help me out in this program i'm doing..the problem is stated below..


(Linked List only)





A c++ program that will accept a no. of int type and add the elements at end of the list..





thanks.hope you can help me out.. ^_^

A c++ program related to linked list..that will accept a no. of int type and add the elements at end of list?
You need- a structure containing a least 2 elements.


1. A value (int in your case)


2. A pointer (to the next structure)





You also need- a pointer, pointing to the START of the list.


"Top" is a good name


You also need- a pointer, pointing to the somewhere in the list.


"Here" is a good name.





Starting from "Top", move "Here" until it is at the end of the list.


Then add another structure,


Point to it,


Move to it,


save your int value.





Repeat for all the int values you need to save.
Reply:http://en.wikipedia.org/wiki/Linked_list


Read up on it, the answer should make itself clear once you understand the "Linked List".





TIP -%26gt; keep a pointer to the "end" of the linked list.


"end" being the last pointer in the linked list... comprehend?


No comments:

Post a Comment