New Member FAQ | Forums | Earn Revenue | Posting Guidelines | Help Topics


ResourcesPractice TestsAsk ExpertsQuestion PapersJobsStudy in UKUniversitiesCollegesCoursesSchoolsTraining


My Profile

Awards & Gifts


Active Members
TodayLast 7 Daysmore...





C program for Multiple Stack


Posted Date:     Total Responses: 0    Posted By: pankaj agarwala   Member Level: Silver   Points/Cash: 3   


C program to perform push,pop and show in a Multiple Stack.




#define MAX 10
#include
#include
int stack[MAX],topA=-1,topB=MAX;
void pushA(int no)
{
if(topA==topB)
{
printf("\n OVERFLOW");
return;
}
stack[++(topA)]=no;
}
int popA()
{
if(topA==-1)
{
printf("\n UNDERFLOW");
return -999;
}
return stack[(topA)--];
}



void showA()
{
int i;
if(topA==-1)
{
printf("\n stack Empty");
return;
}
for(i=topA;i>=0;i--)
{
printf("\n %d",stack[i]);
}
}



void pushB(int no)
{
if(topB-1==topA)
{
printf("\n OVERFLOW");
return;
}
stack[--(topB)]=no;
}



int popB()
{
if(topB==MAX)
{
printf("\n UNDERFLOW");
return -999;
}
return stack[(topB)--];
}



void showB()
{
int i;
if(topB==MAX)
{
printf("\n stack Empty");
return;
}
for(i=topB;i{
printf("\n %d",stack[i]);
}
}






void main()
{
clrscr();

int ch,val;
do
{
printf("\n\n\n 1 PUSH A");
printf("\n 2 PUSH B");
printf("\n 3 POP A");
printf("\n 4 POP B");
printf("\n 5 Show A");
printf("\n 6 Show B");
printf("\n 0 EXIT");
printf("\nENter your CHoice");
scanf("%d",&ch);
switch(ch)
{
case 1:printf("\n enter Number");
scanf("%d",&val);
pushA(val);
break;

case 2: printf("\n enter Number");
scanf("%d",&val);
pushB(val);
break;







case 3: val=popA();
if(val!=-999)
printf("%d popped",val);
break;

case 4 : val=popB();
if(val!=-999)
printf("%d popped",val);
break;




case 5: showA();
break;
case 6: showB();
break;

case 0:break;
default:printf("\n Invalid choice");
}
}while(ch!=0);
getch();
}


Project Feedbacks


No feedbacks found. Be the first to respond...

Post Feedback
You must Sign In to post a feedback.
Next Project: C program to perform various operation on STACK
Previous Project: Java program to reverse a string and to check palindrome or not

Return to Project Index

Post New Project


Related Projects

Subscribe to Email
  • Get Jobs by Email
  • Forum posts by Email
  • Articles by Email



  • website counter

    Online Membersbenson gomez
    Ashish Kumar
    Iti Tyagi
    Sakshi Sood
    Munish kumar
    dks
    Arvind
    siva
    sathishkumar
    Ramakrishna Kambhampati
    Shiyas
    More...



    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    AdSense Revenue Sharing sites   Advertise   Talk to Tony John
    ISC Technologies, Kochi - India
    2006 - 2012 All Rights Reserved.