// Load a stack with the alphabet.
#include
using namespace std;
#define SIZE 27
// Declare a stack class for characters.
class stack {
char stck [SIZE]; //holds the stack
int tos; //index of top of stack
public:
stack () ; //constructor
void push(char ch); // push character stack
char pop () ; // pop character from stack
};
// Initialize the stack.
stack::stack ()
{
cout << "Constructing a stack \n";
tos = 0;
}
/push a character.
void stack ::push(char ch) {
if(tos==SIZE) {
cout<<"stack is full\n";
return; }
stck[tos] = ch;
tos++; }
// pop a characterstack::pop() {
if(tos==0) {
cout << "stack is empty\n";
return 0; //return null on empty stack }
tos--;
return stck[tos];
}
void showstack();
stack loadstack();
int main() {
stack s1;
s1=loadstack();
showstack(s1);
return 0;
}
// Display the contents of a stack.
void showstack(stack o){
char c;
// when this statement ends, the o stack is empty
while(c=o.pop()) cout << c << "\n";
cout << "\n";
}
// Load a stack with the letter the alphabet.
stack loadstack ()
{
stack t;
char c;
for(c= 'a ' ; c <= 'z' ; c++) t.push(c);
return t;
}
Githiari answered the question on May 29, 2018 at 17:35
- Explain five good programming practices(Solved)
Explain five good programming practices.
Date posted: May 29, 2018. Answers (1)
- List five examples of softwares(Solved)
This is a question based on Introduction to Computer Systems unit in Computer science course
Date posted: May 26, 2018. Answers (1)
- List three categories of operating systems(Solved)
List three categories of operating systems.
Date posted: May 26, 2018. Answers (1)
- As a programmer, what is the significance of the Integrated Development Environment(IDE) in programming?(Solved)
As a programmer, what is the significance of the Integrated Development Environment(IDE) in programming?
Date posted: May 26, 2018. Answers (1)
- As a programmer, briefly explain why comments are used when writing a program(Solved)
As a programmer, briefly explain why comments are used when writing a program.
Date posted: May 26, 2018. Answers (1)
- Define the following terms as used in computer programming: (a.) A compiler (b.) A debugger (c.) An algorithm(Solved)
Define the following terms as used in computer programming: (a.) A compiler (b.) A debugger (c.) An algorithm
Date posted: May 26, 2018. Answers (1)
- What is computer programming?(Solved)
What is computer programming?
Date posted: May 26, 2018. Answers (1)
- Using an example, differentiate a code from a program(Solved)
Using an example, differentiate a code from a program.
Date posted: May 26, 2018. Answers (1)
- Explain three techniques of detecting deadlocks in a computer system(Solved)
Explain three techniques of detecting deadlocks in a computer system.
Date posted: May 16, 2018. Answers (1)
- Explain common types of computer networks(Solved)
Explain common types of computer networks.
Date posted: May 16, 2018. Answers (1)
- What is social Engineering?(Solved)
What is social Engineering?
Date posted: May 16, 2018. Answers (1)
- Explain characteristics of information security within an organization? (Solved)
Explain characteristics of information security within an organization?
Date posted: May 16, 2018. Answers (1)
- Giving examples explain threats to data security(Solved)
Giving examples explain threats to data security.
Date posted: May 16, 2018. Answers (1)
- What is a cyber crime?(Solved)
What is a cyber crime?
Date posted: May 16, 2018. Answers (1)
- Describe the difference between an internal and an external hyperlink(Solved)
Describe the difference between an internal and an external hyperlink
Date posted: May 14, 2018. Answers (1)
- What’s the difference between encoding, encryption, and hashing?
(Solved)
What’s the difference between encoding, encryption, and hashing?
Date posted: May 13, 2018. Answers (1)
- Expand on Claude Shannon’s theorem. Differentiate the term confusion and diffusion as envisaged by Shannon to strengthen crypto-algorithm.(Solved)
Expand on Claude Shannon’s theorem. Differentiate the term confusion and diffusion as envisaged by Shannon to strengthen crypto-algorithm.
Date posted: May 13, 2018. Answers (1)
- In DES, the encryption and decryption algorithms are the same. Is that also the case in AES?(Solved)
In DES, the encryption and decryption algorithms are the same. Is that also the case in AES?
Date posted: May 13, 2018. Answers (1)
- What do we mean by public-key cryptography?(Solved)
What do we mean by public-key cryptography?
Date posted: May 13, 2018. Answers (1)
- What is a certificate and why are certificates needed in public key cryptography?(Solved)
What is a certificate and why are certificates needed in public key cryptography?
Date posted: May 13, 2018. Answers (1)