Suppose that a stack s and a queue q of characters are initially empty. Show s and q after each iteration of the second for loop of the following  code fragment:
for(char ch = 'A'; ch <= 'H'; ch++) 
for(int i = 1; i <= 4; i++) { 
    q.Dequeue( ); 
ANSWER: s: A  B  C  E 
          q: E  D  D  C

Could someone tell me how these answers came about step by step...tried figuring them out but could not.

int x;
int* p= &x

which will decrement x?
or none of the above?

would this be none of the above?


what is the value of the expression f(3)?

int Func(int n)
return 0;
else if (n==1)
return 1;
return Func (n-1)+Func(n-2);

Thx for the help

The best way to understand these is to get a compiler and step through while it is debugging or get it to print out at certain steps.

One thing the pointer p is assigned the address of x but x is not assigned a value so i guess your assuming x has a value

int x =3;
int* p= &x;

cout << "value of p: " << *p;
cout <<"address of p: " << p ;

And i say do this in debug mode as your moving the address of p which means it will be pointing at garbage for some of the cout statements

The function is the Fibonacci series and it should be easy for you to find information on the internet

This article has been dead for over six months. Start a new discussion instead.