3) einclude struct stack | 40 9 12 11 7 6 6 12 40 int top; int items[50]; main() void fun(struct stack *); void stk print(struct stack "); struct stack S= (5,(6,7,11,12,9,40}}; stk_print(&S); fun(&S); stk_print(&S); /continues

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 3PE
icon
Related questions
Question

can you explain this question , i just want basic experession for understanding

it is c programming data structures

3)
#include <stdio.h>
struct stack
40 9 12 11 7 6
int top;
6 12 40
int items[50];
main()
void fun(struct stack *);
void stk_print(struct stack *);
struct stack S = (5,(6,7,11,12,9,40}};
stk_print(&S); fun(&S); stk_print(&5);
>l/continues
void stk_print(struct stack "ps)
int k;
for(k=ps->top; k >=0; k--) printf("%d ", ps->items[k]);
printf("\n");
void fun(struct stack *ps)
struct stack Q;
Int k;
Q.top = -1;
do
if((ps -> items[ps -> top]) % 2 == 0)
Q.items[++Q.top] = ps -> items[ps -> top];
}while(ps -> top--);
*ps = Q;
//======
Transcribed Image Text:3) #include <stdio.h> struct stack 40 9 12 11 7 6 int top; 6 12 40 int items[50]; main() void fun(struct stack *); void stk_print(struct stack *); struct stack S = (5,(6,7,11,12,9,40}}; stk_print(&S); fun(&S); stk_print(&5); >l/continues void stk_print(struct stack "ps) int k; for(k=ps->top; k >=0; k--) printf("%d ", ps->items[k]); printf("\n"); void fun(struct stack *ps) struct stack Q; Int k; Q.top = -1; do if((ps -> items[ps -> top]) % 2 == 0) Q.items[++Q.top] = ps -> items[ps -> top]; }while(ps -> top--); *ps = Q; //======
Expert Solution
steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Knowledge Booster
Stack
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning