#include<stdio.h>
// Method to insert a value into a stack
void push(char value, char myStack[], int *top, int sizeOfStack){
if(*top == -1){
myStack[sizeOfStack - 1] = value;
*top = sizeOfStack - 1;
}
else if(*top == 0){
printf("Stack is full. \n");
}
else{
myStack[(*top) - 1] = value;
(*top)--;
}
}
//Method to remove a value from a stack
void pop(char myStack[], int *top, int sizeOfStack){
if(*top == -1){
printf("Stack is empty. \n");
}
else{
printf("Value removed: %c \n", myStack[(*top)]);
// Now if the value removed was the last value in the stack
// you should set top to -1.
// This would show that the stack is now empty
if((*top) == sizeOfStack - 1){
(*top) = -1;
}
else{
(*top)++;
}
}
}
//Method to test the pop and push methods
int main() {
//variable to hold the size of stack
int sizeOfStack = 6;
//create the stack
char myStack[sizeOfStack];
//set the top to -1
//this is to show that the stack is initially empty
int top = -1;
//insert a value tot the stack
push('x', myStack, &top, sizeOfStack);
//print the value on the top
printf("Value on top of stack: %c\n", myStack[top]);
//insert another value to the stack
push('y',myStack, &top, sizeOfStack);
//print the value on the top of the stack
printf("Value on top of stack: %c\n", myStack[top]);
//insert another value to the stack
push('z',myStack, &top, sizeOfStack);
//print the value on the top of the stack
printf("Value on top of stack: %c\n", myStack[top]);
//remove the last inserted value
pop(myStack, &top, sizeOfStack);
//print the value on the top of the stack
printf("Value on top of stack: %c\n", myStack[top]);
//remove another value
pop(myStack, &top, sizeOfStack);
//print the value on the top of the stack
printf("Value on top of stack: %c\n", myStack[top]);
return 0;
}
Sample Output:Value on top of stack: x
Value on top of stack: y
Value on top of stack: z
Value removed: z
Value on top of stack: y
Value removed: y
Value on top of stack: x
Explanation:The code above has been written in c and it contains comments explaining important parts of the code. Please go through the comments.
It also contains a sample output resulting from the run of the program.
PI
s
ne
poem for the
During reading: Work
on the following questions:
suggests
I
a
1
b
What do you predict the poem will be about?
How does the shape support what the titles
How many stanzas does the poem have?
b How many sentences does it have?
3 Read the poem aloud in your group.
2
a
m
Until I saw the Sea by Lilian Moore
ou the Sea
Explanation:
As the qn was copy pasted from another document...the qn seems incorrect... and incomplete..
pls see to it and attach the correct qn...
sorry
7. What is a slide transition?
Answer:
Is this multiple choice? If not, its a visual effect from one slide to another.
Explanation:
Answer:
A slide transition is the visual effect that occurs when you move from one slide to the next during a presentation. You can control the speed, add sound, and customize the look of transition effects
Explanation:
hope this helps:)
The decimal equivalent of the product of 1011 and 1100 is
Answer:
132
Explanation:
We convert each number to base 10 (decimal) and multiply.
So 1011₂ = 1 × 2³ + 0 × 2² + 1 × 2¹ + 1 × 2⁰
= 1 × 8 + 0 × 4 + 1 × 2 + 1 × 1
= 8 + 0 + 2 + 1
= 11₁₀
1100₂ = 1 × 2³ + 1 × 2² + 0 × 2¹ + 0 × 2⁰
= 1 × 8 + 1 × 4 + 0 × 2 + 0 × 1
= 8 + 4 + 0 + 0
= 12₁₀
So, 1011₂ × 1100₂ = 11₁₀ × 12₁₀ = 132₁₀
So, the decimal equivalent of the product of 1011 and 1100 is 132
does trend in computing important for organization management?
Answer:
yes it is...................
The First National Bank debited $100.00 from your checking account into your savings account. What would the transaction descripton be?
Answer:
32 Day Interest Plus
Amount 1 - 32 days (per annum) 33 - 64 days (per annum)
R1 000 - R9 999 0.55% 0.65%
R10 000 - R24 999 0.80% 0.90%
R25 000 - R49 999 1.05% 1.15%
R50 000 - R99 999 1.55% 1.65%
Explanation:
List 5 general safety precautions that you can take when working with a computer equipment.
Answer:
Wear the right clothes, unplug all equipment, keep your work area clean, check for damaged parts, and do not force components into ports.
Explanation:
These are all general safety precautions when working with computer equipment.