#include<iostream.h>
#include<conio.h> struct node { int item; struct node *add; }; void create(struct node *p) { int choice; cout<<"Enter value"; cin>>p->item; cout<<"Do you Want to Continue 1.YES/2.NO"; cin>>choice; if(choice==1) { p->add=(node*)malloc(sizeof(node)); create(p->add); } else { p->add=NULL; } return; } void print(struct node *p) { if(p==NULL)return; cout<<p->item; print(p->add); } int main() { struct node *a; a=(node*)malloc(sizeof(node)); create(a); print(a); getch(); return 0; } |
Tutorials | Tips and Trips | Engineering Concepts | Recent Technology | Invention and Innovation | and much more
Friday, August 31, 2012
C Program for Simple Linked List
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment