0% found this document useful (1 vote)
9K views22 pages

CTC Test

This test measures programming skills using an unfamiliar language. All necessary language information is provided in the test. Each question tests understanding of a language feature described on that page. Later questions may require complex application of earlier information. There are no trick questions, just subtle applications. Only one answer is correct for each question. You have 30 minutes to complete the test and should submit answers separately by email.

Uploaded by

Manohar Manu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
9K views22 pages

CTC Test

This test measures programming skills using an unfamiliar language. All necessary language information is provided in the test. Each question tests understanding of a language feature described on that page. Later questions may require complex application of earlier information. There are no trick questions, just subtle applications. Only one answer is correct for each question. You have 30 minutes to complete the test and should submit answers separately by email.

Uploaded by

Manohar Manu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 22

PROGRAMMING TEST

This test is designed to measure general technical and programming


skills. For this reason, it employs a language with which you are
unlikely to be familiar. All information about the language necessary
to complete the test is contained within the test itself.
Each page of the test contains a description of a language feature or
characteristic, along with a question that tests your understanding of
that feature or characteristic. Subsequent questions build upon
features and descriptions in earlier parts of the test, which
sometimes need to be applied in a complex way. There are no trick
questions, although there are subtle applications of the information
contained in the description portions. There is only one correct
answer to each question.
You have one half-hour to complete the test.
answers in a separate email.

Please write your

30 MINUTE TIME LIMIT


(HONOR SYSTEM)

\\Ctcntdev\Common\where\tests & applications for employment\MIIS.doc

PROGRAMMING TEST

MIIS 3/26/93 PAGE 2

NUMERIC CONSTANTS
Question #1
Numeric constants are integers. I repeat, integers. They range in
magnitude from 0 to 999999999999999 and may be signed or unsigned.
Examples of numeric constants are:
0

-13

1300

14567

Some invalid numeric constants are:


1.2 (not integer)
$1 (not numeric)
1000000000000000 (too large)
Question:

Which of the following is not a legal numeric


constant?
A. 00000007
B. 0
C. 10.2
D. 89

MIIS 3/26/93 PAGE 3

STRING CONSTANTS
Question #2
A string constant is a sequence of 0 to 255 characters chosen from the
standard ASCII 64 character set.
Any legal character (alpha or numeric) may be used as a string and is
designated as such when included in quotation marks (i.e. ABC).
A string constant can also consist of zero characters, that is,
quotation marks around no characters. This is referred to as the nill
or null string.
Some examples are:
ABCDEF

123456

!!!$$

When string constants are read in or written out, the quotation marks
are omitted.
Question:

What kind of constant is this:


A.

String

B.

Numeric

C.

I cant tell.
numeric.

It could be either string or

MIIS 3/26/93 PAGE 4

VARIABLE NAMES
Question #3
A constant retains its value, by definition. The value of a variable
may be changed in the course of a program. A variable may take on any
value that is allowable for either a string or numeric constant.
Unlike some other programming languages (e.g. FORTRAN), the type of
variable is not determined by the name or any kind of declaration.
Variable names are in the format of 1 alphabetic character, followed
by any number of other alphanumeric characters.
Here are some examples of acceptable variable names:
A

ABC

A12

A0

If a variable is set equal to a string value, such as ##$, it will


be a string variable. The very same variable may be converted to a
numeric variable by setting it to a numeric constant.
Question:

Which of the following variable names can have a


string value?
A. I
B. STG
C. S3
D. A and C (above)
E. B and C (above)
F. A and B (above)
G. A, B, and C (above)
H. None of the above

MIIS 3/26/93 PAGE 5

ARRAYS
Question #4
In addition to scalar variables, there are also single dimension
arrays, among others.
The rules for naming arrays are the same as the rules for naming
variables.
Unlike almost all other programming languages, there is no need (and
no capability) for declaring array dimension. An element of an array
is undefined until you put something into it. The only space used in
the system is for those array elements which are defined.
There is also no restriction on the data types of different array
elements. Thus you can have string and numeric values within the same
array.
Question:

Suppose the only variables defined are:


A = 0
A(0) = 1
A(1) = 32767
A(100) = NINETY-NINE
A(32767) = THIS IS A STRING
What is the value of A(A(A+1))?
A. 0
B. THIS IS A STRING
C. 1
D. 32767
E. UNDEFINED

MIIS 3/26/93 PAGE 6

NUMERIC ARITHMETIC OPERATORS


Question #5
Operators connect constants and variables to form expressions.
arithmetic operators include:
+
Addition
1+2=3
Subtraction
3-2=1
*
Multiplication 2*3=6
/
Division
3/2=1 (Integer division only)
&
Minimum
2&3=2
!
Maximum
2!3=3
#
Modulo
13#5=3 (Remainder after division)

The

An important feature of these, and all operators, is that evaluation


in an expression takes place STRICTLY FROM LEFT TO RIGHT. Parentheses
may be used to group parts as in algebra.
The & (minimum), ! (maximum), and # (modulo) operators are probably
less familiar than the other four operators. Below are some examples
of how they can be used:
X#10
X&10
X!10
X!1&10

=
=
=
=

-X!X

Question:

Remainder of X/10
X if X is less than 10, otherwise 10
X if X is greater than 10, otherwise 10
X if X is between 1 and 10,
1 if X is less than 1, and
10 if X is greater than 10
Positive value of X
Now for an example.

What is 1+1*3/2+7#12?

A. 9
B. 7
C. 10
D. 0
E. 131071
F. None of the above

MIIS 3/26/93 PAGE 7

NUMERIC COMPARISON OPERATORS


Question #6
There are three operators for comparing numbers:
<
>
=

Less than
Greater than
Equals

You can combine arithmetic and comparison operators in an expression.


True evaluates to the rubout character (binary all ones), and False
evaluates to (nill). Thus, 1+2=3 evaluates to rubout and 1+3<2
evaluates to (nill).
Question:

Suppose A is a variable with a non-zero numeric value.


Which of the following is false?
A. A#A=0
B. A*A>0
C. (A#A)>(A/A)
D. A+A=A*2

MIIS 3/26/93 PAGE 8

BOOLEAN AND
Question #7
Simple in concept, though sometimes complicated in practice, are the
Boolean operators, & (AND), ! (OR), and ' (NOT).
The symbol & is the Boolean operator for ANDing.
If applied against logical true and false statements, both statements
must be true in order for the AND statement to be true. That is, if
the variables A and B are both true, the statement A&B is true, while
if either A or B (or both A and B) are false, the statement A&B is
false.
Question:

Assume the variable A is true, the variable B is true,


and the variable C is false.
Which of the following is false?
A. A&B
B. B&B
C. A&B&C
D. A&A

MIIS 3/26/93 PAGE 9

BOOLEAN OR
Question #8
The ! is used as the Boolean OR operator.
The logical OR appears between two values or expressions. If either
expression is true, the entire statement is evaluated as true. For
example, in the expression A!B if either variable is true (or if both
variables are true), the expression is evaluated as true.
Question:
Assume that the variable A is true, the variable B is
true, and the variable C is false. Which of the following is false?
A.

A!C

B.

A&C!B

C.

C!C!B

D.

C&A!C

MIIS 3/26/93 PAGE 10

BOOLEAN NOT
Question #9
The operator ' (apostrophe) is used to represent the Boolean NOT. If
it is applied to an integer or a non-nill (true) variable it
reevaluates that integer or variable to a nill (note, not a zero).
When applied to a variable where value is nill (false) it reevaluates
that variable to the rubout character (true).
Question:

If you were asked for


'17
you would answer:
A.

17

B.

14

C.

10001

D.

True

E.

F.

MIIS 3/26/93 PAGE 11

NOT AGAIN
Question #10
The NOT can also be used to modify comparison operators, e.g. 1'>2
(one not greater than 2), 2'<1, 1'=2, and A#B'>B are true.
Question:

Which of the following is false?


A.

'A'=A

B.

A'=('A)

C.

A'<A

D.

'(A=A)

MIIS 3/26/93 PAGE 12

UNARY OPERATORS
Question #11
The (minus) and the ' (not) are also referred to as Unary
operators and may be used in arithmetic expressions. When used in
this way, they apply to the value immediately to their right, BEFORE
it is evaluated in the expression.
In arithmetic expressions, the nill string is evaluated as a zero,
while in logical expressions it is evaluated as a false. For example,
the expression '1 is evaluated as a nill; when it is used in the
arithmetic expression 1+'1 the value of the expression would be 1, but
when used logically in the expression 0='1, the expression is false.
Other examples:
-3=-3
Question:

'1=

'10+0=0

2+3+'3*-3=-15

One of the expressions below is false, which one?


A.

1!2!4!8&'15+0=0

B.

5-5=2+'8*-5

C.

1+'(-3)'>4

D.

'('5)=5

E.

4+'4='4+4

MIIS 3/26/93 PAGE 13

STRING CONCATENATION
Question #12
Concatentation means linking together in a series or chain.
period (.) is the concatenation operator.

The

For example:
HI .THERE is the same as HI THERE
HI. THERE is the same as HI THERE
Question:

If GOD has the value HOLY and HOH has the value
WATER, how do you make HOLY WATER?
A.

GOD.WATER

B.

HOLY.WATER

C.

HOLY. .WATER

D.

GODHOH

E.

.GOD.HOLY

F.

GOD.HOH

G.

GOD..HOH

H.

GOD. .HOH

MIIS 3/26/93 PAGE 14

INTEGER CONCATENATION
Question #13
You can also concatenate integers.

For example:

5.5 = 55

678.910 = 678910

Question:

What is the value of 1.2+3.4?


A.

4.6

B.

46

C.

D.

1234

E.

154

F.

NOT ALLOWED ILLEGAL SYNTAX

MIIS 3/26/93 PAGE 15

DATA CONVERSION
Question #14
You can mix integers and non-integers in a single expression.
example:
123.A = 123A

4A+123 = 127

For

5.5 + 5 = 10

Non-integers are converted to integers as required by the operators.


The non-integer converts to an integer starting with the left-most
character and continuing until encountering a non-numeric character.
In the second example above, 4A converts to 4; in the third example,
5.5 converts to 5.
Question:

What is the value of 1.2+3.4?


A.

44

B.

4.6

C.

154

D.

4.4

E.

46.2

F.

NONE OF THE ABOVE

MIIS 3/26/93 PAGE 16

MORE ON DATA CONVERSION


Question #15
Question:

Suppose A=JOHN, B=JANE, and C=3DOES.


What is the value of 0.A+B+C-3?
A.

0JOHNJANEDOES

B.

C.

JOHNJANE3DOES

D.

E.

A and D

F.

B and C

G.

ALL OF THE ABOVE

H.

NONE OF THE ABOVE

MIIS 3/26/93 PAGE 17

SET AND KILL


Question #16
Variables are defined dynamically. When you log-in to a system, no
variables are defined. In the course of running, a program will
define variables via the READ (R) and SET (S) commands, and undefine
variables via the KILL (K) command. Notice that commands can be
abbreviated to one letter.
As you know, there are two kinds of variables string and numeric. A
variable may be defined via a READ command, in which case it is
automatically a string. The other way a variable can be defined is by
the SET command which can define it as either string or numeric.
The syntax for the SET command is:
S arg1,arg2...argx
S VAR=expression
Assigns the value of the expression to the
variable VAR. The data type of VAR is
determined by the expression.
S VAR1=exp1,VAR2=exp2... Assigns values to multiple variables.
S X=Y
Assigns the value of variable Y to variable X.
Question:

If I say: R Z S X=Z,Y=X
What type of variables are X, Y and Z?
A.

All numeric

B.

All string

C.

X, Y numeric; Z string

D.

X numeric; Y, Z string

E.

X numeric; Y, Z undefined

F.

Cant tell without more information

MIIS 3/26/93 PAGE 18

MORE ON SET
Question #17
Question:

What is the value of A after executing the following:


S A=1,B=1,C=1,A=1+A+(A-1)
A.

B.

C.

D.

MIIS 3/26/93 PAGE 19

MORE ON KILL
Question #18
There is a KILL command which removes a variable and its value from
the symbol table, thus undefining it.
The syntax for the KILL is:
K
A KILL command followed by 2 spaces kills all
variables
K VAR
The variable VAR is killed, if it exists
K (VAR,VAS) All variables except VAR and VAS are killed
The most common use of KILL is to free storage space. Another use is
to flag conditions if a particular value is defined, that means one
thing; and if it is undefined, that means something else.
Question:

K S S=4,T=S+2,Z=T>6 K K,J,S
What variables are defined and what are their values?
A.

S=4,T=S+2,Z=T>6

B.

S=4,T=6,Z=FALSE

C.

S=4,T=6,X=0

D.

S=4,T=6,Z=0

E.

T=6,Z=0

F.

T=6,Z=

G.

No variables are defined

MIIS 3/26/93 PAGE 20

FINAL SET AND KILL


Question #19
Question:

As a final quiz on SET and KILL, after executing the


logic below, what variables are defined and what are
their values?
S T=1,B=1,A=1,B=A=T=(T=B) K (A)
A.

A=1,B=1,,T=1

B.

B=1,T=1

C.

A=0

D.

A=131071

E.

A=3

F.

A=1

MIIS 3/26/93 PAGE 21

$PIECE
Question #20
The $PIECE function is a useful string-valued function. It returns a
sub-string of a base string as defined by a delimiter and one or more
positional indicators. For example:
$P(ONE,TWO,THREE,FOUR,,2)=TWO
This is because the base string (inside the quotes) is
ONE,TWO,THREE,FOUR,. The delimiter is the comma and the 2 is the
positional indicator. This statement says, take the second piece out
of the variable with the piece defined as the portion of the variable
placed between the defined delimiter (comma in this case).
There is an optional argument that allows for the definition of the
positional indicator to multiple places (i.e. take the second through
the fourth pieces would be indicated by replacing the positional
indicator with 2,4).
Further examples:
S X= JOHN DOE;1234 MAIN;ANYTOWN
$P(X;1)=JOHN DOE
$P(X;2)=1234 MAIN
$P(X;2,3)=1234 MAIN;ANYTOWN
Question:

Assume X is as shown above.


executed the statement:

What would appear if we

WRITE $P(X;1,3)
A.

JOHN DOE

B.

JOHN DOE;ANYTOWN

C.

An error

D.

Nothing

E.

JOHN DOE1234MAINANYTOWN

F.

JOHN

G.

JOHN DOE;1234 MAIN;ANYTOWN

MIIS 3/26/93 PAGE 22

You might also like