123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
Program for Stack implementation through Array.

--------------------------------------------------------------------------------



#include <stdio.h>
#include<ctype.h>
# define MAXSIZE 200

int stack[MAXSIZE];
int top; //index pointing to the top of stack
void main()
{
void push(int);
int pop();
int will=1,i,num;
clrscr();
printf("
Program for stack demonstration through array by Amit Mathur and Aditya Tiwari.

<BR>);
while(will ==1)
{
printf("
MAIN MENU:
1.Add element to stack
2.Delete element from the stack<BR>);
scanf("%d",&will);

switch(will)
{
case 1:
printf("
Enter the data... ");
scanf("%d",&num);
push(num);
break;
case 2: i=pop();
printf("
Value returned from pop function is %d ",i);
break;
default: printf("Invalid Choice . ");
}

printf("

Do you want to do more operations on Stack ( 1 for yes, any other key to exit) ");
scanf("%d" , &will);
} //end of outer while
} //end of main


void push(int y)
{

if(top>MAXSIZE)
{
printf("

STACK FULL
<BR>);
return;
}
else
{
top++;
stack[top]=y;
}
}

int pop()
{
int a;
if(top<=0)
{
printf("

STACK EMPTY

");
return 0;
}
else
{
a=stack[top];
top--;
}
return(a);

}

 

 

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG