Program for Stack implementation through Array in C language
#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();
while(will ==1)
{
printf("
MAIN MENU:
1.Add element to stack
2.Delete element from the stack
");
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");
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);
}
Dotnet, DotnetCore, Azure, C#,VB.net, Sql Server, WCF, MVC ,Linq, Javascript and Jquery
Showing posts with label Stack Coding in C language. Show all posts
Showing posts with label Stack Coding in C language. Show all posts
Subscribe to:
Posts (Atom)
Implementing OAuth validation in a Web API
I mplementing OAuth validation in a Web API Implementing OAuth validation in a Web API using C# typically involves several key steps to sec...
-
ViewBag, ViewData, TempData and View State in MVC ASP.NET MVC offers us three options ViewData, ViewBag and TempData for passing data from...
-
// Export Datatable to Excel in C# Windows application using System; using System.Data; using System.IO; using System.Windows.Forms; ...