Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

stacks and its operaaton code

#include<stdio.h>
 
#include<stdlib.h>
  
#define Size 4 
  
int Top=-1, inp_array[Size];
void Push();
void Pop();
void show();
  
int main()
{
    int choice;
     
    while(1)    
    {
        printf("
Operations performed by Stack");
        printf("
1.Push the element
2.Pop the element
3.Show
4.End");
        printf("

Enter the choice:");
        scanf("%d",&choice);
         
        switch(choice)
        {
            case 1: Push();
                    break;
            case 2: Pop();
                    break;
            case 3: show();
                    break;
            case 4: exit(0);
             
            default: printf("
Invalid choice!!");
        }
    }
}
  
void Push()
{
    int x;
     
    if(Top==Size-1)
    {
        printf("
Overflow!!");
    }
    else
    {
        printf("
Enter element to be inserted to the stack:");
        scanf("%d",&x);
        Top=Top+1;
        inp_array[Top]=x;
    }
}
  
void Pop()
{
    if(Top==-1)
    {
        printf("
Underflow!!");
    }
    else
    {
        printf("
Popped element:  %d",inp_array[Top]);
        Top=Top-1;
    }
}
  
void show()
{
     
     
    if(Top==-1)
    {
        printf("
Underflow!!");
    }
    else
    {
        printf("
Elements present in the stack: 
");
        for(int i=Top;i>=0;--i)
            printf("%d
",inp_array[i]);
    }
}
Comment

PREVIOUS NEXT
Code Example
Typescript :: run an applescript 
Typescript :: elements without corner css 
Typescript :: react components for login 
Typescript :: python compare lists unordered 
Typescript :: how to reset windows update components in windows 
Typescript :: cubic beziere curve function 
Typescript :: ts factory pattern 
Typescript :: how to define types in typescript 
Typescript :: typescript json to interface 
Typescript :: nuxtServerInit nuxt3 
Typescript :: ts pipe function 
Typescript :: removing directories in linux 
Typescript :: typescript interview questions 
Typescript :: fetch tweets 
Typescript :: how to print brackets characters in c# 
Typescript :: path represents file or directory java 
Typescript :: how test with limited information 
Typescript :: coding and testing is done in following manner 
Typescript :: typescript class import csv file 
Typescript :: get database num hits django 
Typescript :: network analysis projects code python graph and histogram with data facbook 
Typescript :: typescript checkbox object is possibly null 
Typescript :: famous scientists who contributed to electricity 
Typescript :: can we use function overloading and default arguments at same time in c++ 
Typescript :: what are the parts of an array called 
Typescript :: top 100 employers in the united states 
Typescript :: constraints in database 
Typescript :: import path cannot end with ts 
Typescript :: how to display dotted line betweens 2 series point in high charts react native 
Typescript :: import tsa test 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =