QUESTION 1 (10 points)

Translate each English phrase into a C expression.  Use any variable name desired.  You must declare the variables.

  1. Nine minus the length of a Giraffe’s neck.
  2. The amount in a checking account after 255 hundred dollars is added.

QUESTION 2 (10 points)

This program contains syntax errors.  Rewrite the program with the correct syntax.

#include  <stdio.h>

void main();

{

          int          initial_amount = 7654

          double current_total = 0

          current_total = intial_amount * 7.75;

          print(“Current total is:  %d\n”, current_total)

}       

QUESTION 3 (20 points)

Trace the variables x, y, z, and w for each line of the program given the input:

                    8          9          3          4          20

#include <stdio.h>

void main()

{

          int x, y, z, w;

          scanf("%d%d%d%d", &x, &y, &z, &w);

          x = y % z;

          z = y - x;

          w = w + z - x;

          x = x + y + w;

          w = (y/z)%x;

          printf("%d %d %d %d \n", y, x, z, w); 

}


QUESTION 4 (20 points)

Give the output of this code exactly as it appears on the screen.  Do not include the message “Press any key to continue”.

#include <stdio.h>

void main()

{

printf(“Be my\nValentine!”);

printf(“!!\n!Oh please,\n\noh please\n”);

printf(“Be my Valentine”);

}

QUESTION 5 (20 points)

Will this code add all the odd integers from 1 to 81?  Explain.

#include <stdio.h>

void main()

{

          int total = 0, count = 1;

          while (count < 81) {

                    total = total + count;

                    count = count + 2;

          }

}

QUESTION 6 (20 points)

What gets printed by this code?

#include <stdio.h>

void main()

{

          int j = 1;

          while ( ( j >= -2) && ( j >= -1) ) {

                    printf("This test is almost over.\n");

                    j--;

          }

}