C Program which performs stack operations

Following program performs various stack operations,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
 
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
#define max 20
 
int top=-1,s[max];
void push(int n)
{
    if(top==max-1)
    {
        puts("stack is over flown");
        return;
    }
    else
    {
        top=top+1;
        s[top]=n;
    }
}
void pop()
{
    int del;
    if(top==-1)
    {
        puts("stack is underflown");
        return;
    }
    else
    {
        del=s[top];
        printf("\n poped element is %d",del);
        top=top-1;
    }
}
void display()
{
    int i;
    if(top==-1)
        puts("stack is empty");
    else
    {
        for(i=top;i>=0;i--)
            printf("\t%d",s[i]);
    }
}
void main()
{
    int opt,n;
    do
    {
        printf("\n 1.push");
        printf("\n 2.pop");
        printf("\n 3.display");
        printf("\n 4.exit");
        printf("enter ur option");
        scanf("%d",&opt);
        switch(opt)
        {
        case1:printf("\n enter any element to push");
            scanf("%d",&n);
            break;
        case2:pop();
            break;
        case3:display();
            break;
        case4:exit(0);
            break;
        }
    }
    while(1);
}

6 Responses to “C Program which performs stack operations”

  1. 说道:I cling on to listening to the news uptade lecture about receiving boundless online grant applications so I have been looking around for the most excellent site to get one. Could you advise me please, where could i acquire some?

    Reply
      • All I have to say is “That’s it? You gotta be shittin me!”:)Very nice list, and you didn’t even mention Memphis in May, Gairialdb’s BBQ Pizza, Chocolate Butter Pie, or that a famous ER doc once went to school there.

        Reply
    • Anonymousبسم الله الرحمن اŠÙرحÙÙ„…بسم الله الرحمن الرحيمFirst thing I want to say :Far from islam , america have a lot of these situation ! Not with just saudi boys ..I don’t mean I gave them the rightNo but it’s wired how much the overreaction about the story !!I am not against you mandre and I am absolutely not with himEvery one must take the responsibility of their faults !In islam there is no sex without marriage. Then there is no child without parents (thanks allah I am a muslim )

      Reply
  2. Paulina

    YO , MI, ME, CONMIGO Me decía una persona una vez que prefería beber y comer que follar, porque beber y comer podía hacerlo cuando quisiera y no necesitaba a nadie y para follar siempre necesitaba de aloneiu.Vgta el comentario: 2  2

    Reply

Leave a Reply