Home
Q&A
Education
Technology
Credit
General
Health
Insurance
Questions
Ask a Question
Implement a”c” program to stack size – 8 forPush (10), Push (20), Pop, Push (10), Push (20), POP, POP, Pop,
Home
Education
Implement a”c” program to stack size – 8...
asked
Nov 26, 2021
in
Education
by
JackTerrance
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
computer-science-interview-questions
computer-science-questions
1
Answer
0
votes
answered
Nov 26, 2021
by
JackTerrance
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
Q: Implement a”c” program to stack size – 8 forPush (10), Push (20), Pop, Push (10), Push (20), POP, POP, Pop,
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 25, 2021
in
Education
by
JackTerrance
computer-science-interview-questions
computer-science-questions
0
votes
Q: Push (10), Push (20), Pop, Push (10), Push (20), POP, Pop, Pop2x Implement a “c” program to stack size – 8 for
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
computer-science-interview-questions
computer-science-questions
0
votes
Q: Push (10), Push (20), Pop, Push (10), Push (20), POP, Pop, Pop2x Implement a “c” program to stack size – 8 for
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
computer-science-interview-questions
computer-science-questions
0
votes
Q: Push (10), Push (20), Pop, Push (10), Push (20), POP, Pop, Pop2x Implement a “c” program to stack size – 8 for
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
computer-science-interview-questions
computer-science-questions
0
votes
Q: You are asked to perform a queue operation using a stack. Assume the size of the stack is some value ‘n’ and there are ‘m’ number of variables in this stack. The time complexity of performing deQueue operation is (Using only stack operations like push and pop)(Tightly bound).
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
data-structures-&-algorithms-interview-questions
data-structures-&-algorithms-interview-questions-answers
data-structures-&-algorithms-multiple-choice-questions
data-structures-&-algorithms-mcq-with-answers
data-structures-&-algorithms-mcq
data-structures-&-algorithms-questions
0
votes
Q: Consider you have an array of some random size. You need to perform dequeue operation. You can perform it using stack operation (push and pop) or using queue operations itself (enQueue and Dequeue). The output is guaranteed to be same. Find some differences?
Consider you have an array of some random size. You need to perform dequeue operation. You can perform ... from above options Data Structures and Algorithms questions and answers...
asked
Nov 14, 2021
in
Education
by
JackTerrance
data-structures-&-algorithms-interview-questions
data-structures-&-algorithms-interview-questions-answers
data-structures-&-algorithms-multiple-choice-questions
data-structures-&-algorithms-mcq-with-answers
data-structures-&-algorithms-mcq
data-structures-&-algorithms-questions
0
votes
Q: Plz write a program for the following pattern in Java class 10 ICSE2 6 12 20 30 424 6 8 10 122 2 2 20 0 0000
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
computer-science-interview-questions
computer-science-questions
0
votes
Q: Consider yourself to be in a planet where the computational power of chips to be slow. You have an array of size 10.You want to perform enqueue some element into this array. But you can perform only push and pop operations .Push and pop operation both take 1 sec respectively. The total time required to perform enQueue operation is?
Consider yourself to be in a planet where the computational power of chips to be slow. You have an ... from above options Data Structures and Algorithms questions and answers...
asked
Nov 14, 2021
in
Education
by
JackTerrance
data-structures-&-algorithms-interview-questions
data-structures-&-algorithms-interview-questions-answers
data-structures-&-algorithms-multiple-choice-questions
data-structures-&-algorithms-mcq-with-answers
data-structures-&-algorithms-mcq
data-structures-&-algorithms-questions
0
votes
Q: Q.32 :-What will the SWAP macro in the following program beexpanded to on preprocessing? will the code compile?#include<stdio.h>#define SWAP(a, b, c)(ct; t=a, a=b, b=t)int maino{intx=10, y=20;SWAP(x, y, int);printf(“%d %d\n”, x, y);
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
computer-science-interview-questions
computer-science-questions
0
votes
Q: Write a menu-driven program to print the following patterns, where number of rowsfor the pattern should be the user input:a. Press 1 to print the following pattern:55 85 8 135 8 13 205 8 13 20 29b. Press 2 to print the following pattern:22 92 9 282 9 28 652 9 28 65 126c. Print the following series:
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
computer-science-interview-questions
computer-science-questions
0
votes
Q: The number of permanent members of the Security Council of United Nations are (a) 5 (b) 7 (c) 8 (d) 10
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
computer-science-interview-questions
computer-science-questions
0
votes
Q: 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(a) 10(b) 11(c) 12
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
computer-science-interview-questions
computer-science-questions
0
votes
Q: If P(A) = 4/5 , and P(A ∩ B) = 7/10 , then P(B | A) is equal to (A) 1/10 (B) 1/8 (C) 7/8 (D) 17/20
If P(A) = 4/5 , and P(A ∩ B) = 7/10 , then P(B | A) is equal to (A) 1/10 (B) 1/8 (C) 7/8 (D) 17/20 Select the correct answer from above options...
asked
Nov 20, 2021
in
Education
by
JackTerrance
probability-interview-questions
probability-interview-questions-answers
probability-multiple-choice-questions
probability-mcq-with-answers
probability-mcq
probability-questions
cbse-class-10
0
votes
Q: If P(A ∩ B) = 7|10 and P(B) = 17|20, then P(A|B) equals A. 14/17 B. 17/20 C. 7/8 D. 1/8
If P(A ∩ B) = 7|10 and P(B) = 17|20, then P(A|B) equals A. 14/17 B. 17/20 C. 7/8 D. 1/8 Select the correct answer from above options...
asked
Nov 20, 2021
in
Education
by
JackTerrance
probability-interview-questions
probability-interview-questions-answers
probability-multiple-choice-questions
probability-mcq-with-answers
probability-mcq
probability-questions
cbse-class-10
0
votes
Q: A fair die is thrown 20 times. The probability that on the 10th throw, the fourth six appears is `^20 C_(10)xx5^6//6^(20)` b. `120xx5^7//6^(10)` c. `8
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
probability-interview-questions
probability-interview-questions-answers
probability-multiple-choice-questions
probability-mcq-with-answers
probability-mcq
probability-questions
...