physics chemistry maths science forums
become expert I help I sign up I login
refer a friend - earn nickels!!   
 advanced
 
Home
Ask & Discuss Questions
Study Material
Experts Zone
Hang Out!

Ask & Discuss Questions with Community & Experts

Moderation Team
 90 chars left    advanced
Ask iit jee aieee pet cbse icse state board community Community Discussion Question: c++ find error
Forum Index -> Course Material like the article? email it to a friend.  
Author Message
ankur.kkhurana (888)

Blazing goIITian

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

ankur.kkhurana's Avatar

total posts: 986    
offline 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";
}







Chat with ankur khurana
    
nadeemoidu (1184)

Blazing goIITian

Olaaa!! Perrrfect answer. 200  [292 rates]

nadeemoidu's Avatar

total posts: 487    
offline 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.kkhurana (888)

Blazing goIITian

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

ankur.kkhurana's Avatar

total posts: 986    
offline Offline
thanks buddy

Chat with ankur khurana
 this reply: 0 points  (with Olaaa!! Perrrfect answer.   in 0 votes )   [?]
 
You have to be logged on to rate
  
umang (229)

Blazing goIITian

Olaaa!! Perrrfect answer. 35  [62 rates]

umang's Avatar

total posts: 873    
offline 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
  
 
Forum Index -> Course Material
Go to:   

Top Offers for goIITians
Correspondence Courses
Brilliant Tutorials
Narayana Institute
Aakash Institute
Classroom/Crash Courses
Narayana - Kota , Delhi , Others
Brilliant Tutorials - Class , Crash
Aakash Institute - Medical , Engg
Online Test Series
Brilliant Tutorials
Narayana Institute
Aakash Institute
Mahesh Tutorials
AMITY      Sri Chaitanya