/*WAP of STACK*/
#include<stdio.h>
#include<conio.h>
#include<alloc.h>
#include<process.h>
struct stack
{
int no;
struct stack *next;
}*top=NULL;
typedef struct stack st;
void push();
int pop();
void display();
void main()
{
char ch = 'y';
int choice,temp;
clrscr();
do
{
printf("\n1:push");
printf("\n2:pop");
printf("\n3:display");
printf("\n4:exit");
printf("\nEnter your choice");
scanf("%d",&choice);
switch(choice)
{
case 1:push();
break;
case 2:temp=pop();
printf("the deleted element is%d",temp);
break;
case 3:
display();
break;
case 4:
exit(0);
break;
default:
printf("\n wrong choice");
}
printf("do you want continue(y/n)");
flushall();
scanf("%c",&ch);
}
while(ch =='Y'|| ch =='y');
}
void push()
{
st*P;
P=(st*)malloc(sizeof(st));
printf("\nthe number");
scanf("%d",&P->no);
P->next=top;
top=P;
}
int pop()
{
st*P;
P=top;
if(top==NULL)
{
printf("stack is already empty");
getch();
exit(0);
}
else
{
top=top->next;
free(P);
}
return(P->no);
}
void display()
{
st*P;
P=top;
while(P->next != NULL)
{
printf("\n=%d",P->no);
P=P->next;
}
printf("\nno=%d",P->no);
}
How to earn online:
Step - 1 :
signup for PayPal, to recieve your online earning
click here:
https://www.paypal.com/in/mrb/pal=CZ7224TZBMCBL
step - 2 :
Read & Rate interesting articales to earn money!
per artical $0.03 to $0.10
link: http://www.readbud.com/?ref=4096068
EARN MONEY BY BUMPING SITES, DAILY 5 ADS TO CLICK,
PER CLICK 0.02$, DAILY 0.10$ EARN, MINIMUM PAYOUT 15$,
YES ITS FREE TO JOIN
http://www.MoneyBumper.com/Main.cfm?R=134526
No comments:
Post a Comment