Purchase Solution

C++ Output Functions

Not what you're looking for?

Ask Custom Question

C++. See attached file for full problem description.

Question 1

What would the operation isEmptyStack return if applied to the stack above?

0

5

true

false

Question 2

template<class Type>
void stackType<Type>::operation1(const Type& newItem)
{
if(!isFullStack())
{
list[stackTop] = newItem;
stackTop++;
}
else
cerr<<"Cannot add to a full stack."<<endl;
}

Which stack operation does operation1 above define?

top

pop

push

initializeStack

Question 3

Stack s;

s.push(3);
s.push(7);
x = s.pop();
s.push(5);
y = s.pop();
z = s.pop();

Given the sequence of operations above, what is the value of x?

0

3

5

7

Question 4

Given the sequence of operations above, what is the value of z?

0

3

5

7

Question 5

If you applied the operation pop to the stack above, which book would be left on top of the stack?

Applied Math

World History

Chemistry

English

Question 6

What is the effect of the operation empty of the stack container class?

To empty the stack

Return the number of items in the stack

Return true if the stack is empty and false otherwise

Return true if the stack is nonempty and false otherwise

Question 7

Which operation would you use to return the Applied Math book from the stack above?

top

pop

push

return

Question 8

What is the value of the postfix expression: 5 4 * 3 + ?

17

23

27

35

Question 9

What is the equivalent postfix expression for the infix expression: (x - y) * (v + w)?

x v * y w - +

- x y + v w *

x * y + v * w -

x y - v w + *

Question 10

#include <iostream>
#include "myStack.h"

using namespace std;

int main()
{
stackType<int> intStack(50);
stackType<int> tempStack;

intStack.push(18);
intStack.push(21);
intStack.push(25);

tempStack = intStack;

while(!tempStack.isEmptyStack())
{
cout<<tempStack.top()<<""; //output 1
tempStack.pop();
}

cout<<endl;

cout<<intStack.top()<<endl; //output 2

return 0;
}

What is output 1 above?

18 21 25

21 18 25

25 21 18

25 18 21

Attachments
Purchase this Solution

Solution Summary

The C++ output functions are examined. The equivalent postfix expression for the infix expression is determined.

Purchase this Solution


Free BrainMass Quizzes
Javscript Basics

Quiz on basics of javascript programming language.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.