| Author |
Message |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 17 Dec 2007 15:01:27 IST
|
|
|
this is program please try to run it and tell me result as soon as possible
#include<iostream.h> #include<process.h> #include<conio.h> struct node{ int info; node *next;
}*start,*newptr,*save,*ptr;
node *createnode(int); void insertbeg(node*); void dislay(node*); void main() { start=NULL; int inf; char ch='y'; while(ch=='y'||ch=='Y') { cout <<"\nEnter the information for new node"; cin>>inf; cout<<"\ncreating new node, press enter to continue"; getch(); newptr=createnode(inf); if(newptr!=NULL) {cout<<"/nnew node created successfully.press enter ....."; getch(); } else { cout<<"/ncannot create node"; exit(1); } cout<<"/nputting it in the beginging"; insertbeg(newptr); cout<<"/nnow the list is";
dislay(start); cout<<"/ndo you want to continue(y/n)?"; cin>>ch; } } node *createnode(int n) { ptr=new node; ptr->info=n; ptr->next=NULL; return ptr; } void insertbeg(node *np) {if(start==NULL) start=np; else{ save =start; start=np; np->next=save; } }
void display(node *np) { while (np!=NULL) {cout<<np->info<<"->"; np=np->next; } cout<<"!!!/n"; }
|
Chat with ankur khurana |
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 17 Dec 2007 17:19:30 IST
|
|
|
u've used 2 different spellings for "display()" .
and it is really important to delete any pointers u use . it can cause the compiler to work in a weird way.
dont write newline as /n , it is \n
stack can be implemented much easily by avoiding the use of function for each and every step.
|
this reply: 5 points
(with 1 
in 1 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 17 Dec 2007 19:06:01 IST
|
|
|
thanks buddy
|
Chat with ankur khurana |
this reply: 0 points
(with 0 
in 0 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
![[Post New]](/templates/default/images/icon_minipost_new.gif) 17 Dec 2007 21:26:43 IST
|
|
|
Hey ! I got a project from my friend to submit in skul but the program uses "this" operatorwhich is not in course ! can u suggest me some alternative for it ????
|
Umang |
this reply: 0 points
(with 0 
in 0 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
|
|