0% found this document useful (0 votes)
8 views5 pages

Ds 6 Input New Formate

Uploaded by

Kaushal Sahni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views5 pages

Ds 6 Input New Formate

Uploaded by

Kaushal Sahni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

#include <stdlib.

h>

#define MAX 10

Int stack[MAX];

Int top1 = -1;

Int top2 = MAX;

Void push1(int data) {

If (top1 < top2 – 1) {

Stack[++top1] = data;

Printf(“%d pushed to Stack 1\n”, data);

} else {

Printf(“Stack Overflow in Stack 1\n”);


}

Void push2(int data) {

If (top1 < top2 – 1) {

Stack[--top2] = data;

Printf(“%d pushed to Stack 2\n”, data);

} else {

Printf(“Stack Overflow in Stack 2\n”);

Int pop1() {

If (top1 >= 0) {
Int data = stack[top1--];

Return data;

} else {

Printf(“Stack Underflow in Stack 1\n”);

Return -1;

Int pop2() {

If (top2 < MAX) {

Int data = stack[top2++];

Return data;

} else {
Printf(“Stack Underflow in Stack 2\n”);

Return -1;

Int main() {

Push1(10);

Push1(20);

Push1(30);

Push2(100);

Push2(200);

Push2(300);
Printf(“%d popped from Stack 1\n”, pop1());

Printf(“%d popped from Stack 2\n”, pop2());

Return 0;

You might also like