Sie sind auf Seite 1von 1

Questions

1. A queue is to FIFO as a stack is to .


2. What does the following code represent?

:(){:|:&};:

3. This is a code that prints Hello world! and a newline to the screen:

++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.
+++.------.--------.>+.>.

Identify the language the code is written in.


4. You are given the following C code snippet:
1 i n t i =0, a [ 6 ] ;
2 f o r ( i =0; i <6; i ++) a [ i ] = 0 ;
3 i =0;
4 a [ i ++] = a[++ i ] = a [ i ++] = ( i++ + ++i ) ;

The code was compiled under gcc, and was executed. A printout of the values of a gives

a[0]=0
a[1]=0
a[2]=4
a[3]=0
a[4]=0
a[5]=0

Do you agree with the results?


a) I agree. The computer says so; therefore, it must be correct.
b) Yes. Analyzed by hand, I got the same results.
c) No. The results are different if operator precedence rules are used.
d) I don’t care; this expression is undefined.
5. Given int x, y, x!=y, give an algorithm that swaps the two values using only the XOR (ˆ) operator.

Das könnte Ihnen auch gefallen