in Education by
Implement a”c” program to stack size – 8 for Push (10), Push (20), Pop, Push (10), Push (20), POP, POP, Pop, Pugh (20), Pop & draw final output. Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
Program: #include int SIZE = 8; int stack[8]; int top = -1; void Pop() { if(top == -1) { printf(“Could not retrieve data, Stack is empty.\n”); } else { printf(“Data Popped : %d \n” , stack[top]); top = top – 1; } } void Push(int data) { if(top == SIZE) { printf(“Could not insert data, Stack is full.\n”); } else { top = top + 1; stack[top] = data; } } void display() { if(top == -1) { printf(“Could not retrieve data, Stack is empty.\n”); } else { for(int i = 0 ; i <= top ; i++) { printf(“%d” , stack[i]); } } } int main() { Push(10); Push(20); Pop(); Push(10); Push(20); Pop(); Pop(); Pop(); Push(20); Pop(); display(); return 0; } Output: Data Popped : 20 Data Popped : 20 Data Popped : 10 Data Popped : 10 Data Popped : 20 Could not retrieve data, Stack is empty.

Related questions

0 votes
    Implement a c program to stack size - 8 for Push (10), Push (20), Pop, Push (10), Push (20), POP, ... 20), Pop & draw final output. Select the correct answer from above options...
asked Nov 26, 2021 in Education by JackTerrance
0 votes
    Push (10), Push (20), Pop, Push (10), Push (20), POP, Pop, Pop 2x Implement a c program to stack ... 20), Pop & draw final output. Select the correct answer from above options...
asked Dec 5, 2021 in Education by JackTerrance
0 votes
    Push (10), Push (20), Pop, Push (10), Push (20), POP, Pop, Pop 2x Implement a c program to stack ... 20), Pop & draw final output. Select the correct answer from above options...
asked Nov 26, 2021 in Education by JackTerrance
0 votes
    Push (10), Push (20), Pop, Push (10), Push (20), POP, Pop, Pop 2x Implement a c program to stack ... 20), Pop & draw final output. Select the correct answer from above options...
asked Nov 25, 2021 in Education by JackTerrance
0 votes
    You are asked to perform a queue operation using a stack. Assume the size of the stack is some value ... from above options Data Structures and Algorithms questions and answers...
asked Nov 14, 2021 in Education by JackTerrance
0 votes
    Plz write a program for the following pattern in Java class 10 ICSE 2 6 12 20 30 42 4 6 8 10 12 2 2 2 ... spam. Answer only if you know Select the correct answer from above options...
asked Nov 30, 2021 in Education by JackTerrance
0 votes
    Q.32 :-What will the SWAP macro in the following program be expanded to on preprocessing? will the code compile? ... y); return 0; Select the correct answer from above options...
asked Nov 30, 2021 in Education by JackTerrance
0 votes
    Write a menu-driven program to print the following patterns, where number of rows for the pattern should be the user ... 2 4 8 32 Select the correct answer from above options...
asked Nov 29, 2021 in Education by JackTerrance
0 votes
    The number of permanent members of the Security Council of United Nations are (a) 5 (b) 7 (c) 8 (d) 10 Select the correct answer from above options...
asked Aug 3, 2022 in Education by JackTerrance
0 votes
    If page size of 1MB memory is 1 KB then the number of higher order bits of address bus used to denote page number is ( ... (c) 12 (d) 9 Select the correct answer from above options...
asked Dec 17, 2021 in Education by JackTerrance
0 votes
    A fair die is thrown 20 times. The probability that on the 10th throw, the fourth six appears is ^20C10 56/620 ... D. none of these Select the correct answer from above options...
asked Nov 16, 2021 in Education by JackTerrance
...