Here is a sample test in preparation for the mid-term test on
Wednesday, 18th February (in the regular Wednesday classroom)

The answers will follow in the next mail message

Brian Perry
=========================

Instructor:  B. Perry                  Student: 

A. FUNDAMENTALS 

USE THE FOLLOWING VARIABLES FOR EACH QUESTION IN SECTION A.
Think of the values as "reset" at the at start of each question.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
     int a = 3;
     int b = 4;
     int c;
     int *x;
     char k;
     char str[] = "I am a string";
     
1. Is (b==a) true or false?

2. is (b=a) true or false?

3. what is the value of c BEFORE and AFTER this instruction?

          c = a+b;

4. what are the values of a, b and c after (all of) the following
three instructions?  (this is a trick question)

          x = &a;
          c = *x;
          b = &x;

5. what are the values of the following?

          *str+3

          str[6]

          &str[6]

          str

          str[strlen(str)]

7. Complete the following statements:

     In C an expression is false if it evaluates to .........

     In C an expression is true if it evaluates to .........


8.   How much memory (bytes) do each of the following add to the
     size of a program?

     char X = 'A';                 char *X = "ABC";

B. PROGRAMMING STYLE AND TESTING

1. What is the type (???) and the purpose of the following
function?

/* xxx.c - a function which ... */

??? xxx(char *s)
{
     int n;
     for (n = 0; *s != '\0'; s++)
          n++;
     return (n);
}




Is there a "C standard library function" which does this job? If so
what is it's name and what include file contains it's prototype?



2.   What is an appropriate type (???) and what is purpose of the
     following function?


/* yyy.c - a function which ... */

??? yyy(int *pa, int *pb)
{
     int temp = 0;
     temp = *pa;
     *pa = *pb;
     *pb = temp;
}




Is there a "C standard library function" which does this job? If so
what is it's name and what include file contains it's prototype?
