become expert | help | login
refer a friend - earn nickels!!
 advanced

  Ask & Discuss Questions with Community & Experts

Moderation Team
  500 chars left
Ask community Community Discussion Question: c++ find error
Reply Forum Index -> Course Material originally posted here on IIT-JEE / AIEEE community   
Email  
Author Message
ankur khurana (527)

Blazing IASian

Olaaa!! Perrrfect answer. 87  bad job dude!! I dont approve of this answer! 1  [135 rates]

ankur khurana's Avatar

total posts: 1029    
Offline
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";
}







adversities cause some men to break other to break records............i m of the other type....... :-)
    
Nadeem (1243)

Blazing IASian

Olaaa!! Perrrfect answer. 211  [305 rates]

Nadeem's Avatar

total posts: 521    
Offline
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 Olaaa!! Perrrfect answer.   in 1   votes   )     [?]
 
You have to be logged on to rate
  
ankur khurana (527)

Blazing IASian

Olaaa!! Perrrfect answer. 87  bad job dude!! I dont approve of this answer! 1  [135 rates]

ankur khurana's Avatar

total posts: 1029    
Offline
thanks buddy

adversities cause some men to break other to break records............i m of the other type....... :-)
  this reply:   0 points  (with Olaaa!! Perrrfect answer.   in 0   votes   )     [?]
 
You have to be logged on to rate
  
Umang (224)

Blazing IASian

Olaaa!! Perrrfect answer. 34  [61 rates]

Umang's Avatar

total posts: 926    
Offline
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 Olaaa!! Perrrfect answer.   in 0   votes   )     [?]
 
You have to be logged on to rate
  
 
reply Forum Index -> Course Material
Go to: 
Sponsored Links
preparing for IAS ?
Brilliant Tutorial's correspondence
Complete course. Buy Online Now !

goiit.com/Brilliant-UPSC-postal

preparing for IAS ?
free online tests
Complete course. FREE Analysis !

go4ias.com/ACCELERATE

Preparing for IES ?
Brilliant Tutorial's correspondence
full course prep. Buy Online !

goiit.com/brilliant-IES

preparing for BSNL JTO ?
solved, model paper, rank predictor
online, study material. Buy Online!

go4ias.com/BSNL-JTO

preparing GATE 2010?
solved, model Papers,study Material
courses from Brilliant. Buy Now !

goiit.com/Brilliant-GATE