15 November 2011

A DSA program of stacking.


#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
struct node
{
int info;
struct node *next;
};
struct stack
{
struct stack *top,*next;
};
void main()
{
char ch='y';
struct node *node1;
struct stack *stack1;
stack1->top=NULL;
while(ch=='y')
{
node1=malloc(sizeof (struct node));
if(stack1->top==NULL)
{
node1->next=NULL;
}
else
{
node1->next=NULL;
}
      // stack1=node1;
printf("\n Enter any value");
scanf("%d",& node1->info);
printf("\n Enter your choice (y/n):");
fflush(stdin);
scanf("%c", &ch);
}
for(  ;stack1->top!=NULL;stack1->top=stack1->top->next)
{
printf("%d",node1->info);
}
getch();
}

0 comments:

Post a Comment