Demo entry 6023339

suck my dick

   

Submitted by Sayan Saha on Sep 18, 2016 at 00:55
Language: C. Code size: 1.3 kB.

//header files
#include<stdio.h>
#include<stdlib.h>
#define max_size 5
//user defined function prototypes
void push();
void pop();
void display();

//global variable declare
int stack[max_size];
int top;

void main()
{
	int option;
	top=-1;
	
	options:
		printf("-----------------------\n");
		printf("1>\tpush,\n");
		printf("2>\tpop,\n");
		printf("3>\tdisplay,\n");
		printf("4>\texit,\n");
		printf("-----------------------\n: ");
		scanf("%d",&option);
		system("cls");
		switch(option)
		{
			case 1:
				push();
				break;
			case 2:
				pop();
				break;
			case 3:
				display();
				break;
			case 4:
				exit(0);
				break;
			default:
				printf("Enter proper number,\n");
				goto options;
		}
		
	goto options;
}

//user defined function definitions
void push()
{
	if(top==max_size-1)
	{
		printf("stack is full.\n");
	}
	else
	{
		top++;
		printf("Enter the value : ");
		scanf("%d",&stack[top]);
	}
}

void pop()
{
	if(top==-1)
	{
		printf("stack is empty.\n");
	}
	else
	{
		printf("%d is removed.\n",stack[top]);
		top--;
	}
}

void display()
{
	int i;
	if(top==-1)
	{
		printf("stack is empty.\n");
	}
	else
	{
		for(i=top;i>=0;i--)
		{
			printf("%d\n",stack[i]);
		}
	}
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).