CSE1320-501                                                     Quiz 1                                                            Fall 2001

 

A)                              True or False

            The operator “ ! “ is a unary arithmetic operator. 1 pt

            Functions with no parameters must return type void. 1 pt

            Compound assignment operators have lower precedence than logical operators. 1 pt

            ANSI C coders typically use preprocessor directives to declare local variables. 1 pt

            printf does formatted output taking one additional parameter for each conversion specification in the control string. 1 pt

            C is case-insensitive. 1 pt

            An expression with a non-zero value is evaluated as true. 1 pt

 

 

 

B)                               Short answer/Solve

 

How many times will line 2 execute?                  4 pts

 

C)            j = k = 10;

D)            while (k)

E)             {

F)             j -=2;

G)            k = j;

H)           {

 

What value will z have after this statement is executed?                     4 pts

 

                  z = 7 ! = 4;

 

 

Name one benefit and one drawback of using shortcuts in C syntax. [Note: “Less typing” is not an acceptable benefit for this question.] 4 pts

 

Benefit:

 

Drawback:

 

 

I)                                                                    Put the following operators in order by precedence from highest (on the left) to lowest (on the right). Ignore the commas. 4 pts

                                    +, ||, ( ), %, *=, (unary)+, ++

 

Highest                                                                                                         Lowest

 

J)                                                                    Fill in the blank

                                    Preprocessor directive used to link in files from libraries 3 pts

                                    Kind of variable declared within a block (not a type of variable) 3 pts

                                    Another name for the remainder operator 3 pts

 

K)                                                                  Multiple choice

 

The standard library function abs(x) :             2 pts

 

A)        makes x an absent variable

B)        abstracts x to the next level

C)        automatically stops x when it is out of control

D)        takes the absolute value of x

 

 

Which of the following is not a legal identifier?            2 pts

 

A)        _able                                       C)        for_do

B)        60_sec                                     D)        _100_count

 

Which of the following will evaluate to false if m = 2 and p = 4 initially?             2 pts

 

L)             m ! = p               C)        p % m

M)           m * m = = p      D)        p = m + m

 

Which operator is not guaranteed to give correct answers in ANSI C?               2 pts

 

A)        &&                                          C)        !

B)        *                                              D)        /

 

If a function is declared as follows:

                                    int fred (void);

and is properly defined, which of the following is a legal function call in ANSI C?                                     2 pts

 

A)        int fred (void);                      C)        int fred ();

B)        fred ();                                    D)        fred (void);

 

 

 

CQ1.1                                                     11 September 2001                                          JCM Tiernan

 

ÿ