1. Fillin your name and your student ID# on the answer sheet (write it in AND fill in the bubbles). All student ID numbers must include ten digits beginning with two leading zeros (write it in AND fill in the bubbles). An incorrect student ID number will result in a zero for this 
  2. Do not fill in the section or the test
  3. You must be in your assigned seat to receive credit for this
  4. Make sure you have all 35 questions to this exam. You should answer every question. All questions only have one best Please be careful when filling in your answers, any answer determined to be unreadable by Instructional Data Processing will be considered incorrect. Only the answer on your answer sheet can be considered when grading.An operator precedence table is provided on the back of this exam.
  5. NO QUESTIONS WILL BE ANSWERED DURING THE EXAM. We do not answer questions during the exam due to the limited number of staff members present. It is easier for us to “throw out” a test question with an error than it is to answer questions or to make an announcement during the examination period. Manage your timeaccordingly!
  6. You must assume that all C programs and code segments are implemented on the itap machine and would be compiled with the gcc compiler as set up during the first week of the semester. When segments of codeare presented you may assume that the appropriate include statements are present and that the code would be inside of a fully operational function or program.
  7. Protect your work and keep your focus on your own exam. It is considered dishonest if you copy from anotherstudent or to permit another student to copy from  If a spotter has any reason to suspect questionable behavior, you may be asked to move to another seat. Anyone found to violate course policies will receive a failing grade for the course and will be referred to the Office of the Dean of Students.
  8. You are NOT permitted to use any resources during this exam. This includes but is not limited to; texts, notes, calculators, cell phones, MP3 players, and computers.If your cell phone audibly rings during the exam you will be required to immediately submit your exam and leave the testing
  9. When you are finished with the exam, do not raise your hand, but proceed back to the lobby to submit your answer form and exit the You will be required to show photo identification before we can accept your work. You will keep this exam form (unless you are being proctored by the DRC). You may not return to your seat once you have submitted yourexam.
  10. Your score (and exam answers) will appear on Blackboard as soon as possible. Do not contact course staff members about mistakes (if any) until answers are
  11. When time is called ALL writing must stop. You are not permitted to continue to make revisions to any answer on your exam once time has been
  12. All lecture and lab sections will meet as scheduled for this

 

Use the code segment below for problems 1 – 3

int x = 7; int y = 3; int z = 11;

 

int result;

 

result = x++ > 7 || y++ > 3 && z++ > 11; result += x++ % 2 == 0 && z++ % 2 == 0;

result += y++ % 2 == 1 || z++ % 2 == 1; printf(“result: %d\n”, result); printf(“x + y: %d\n”, x + y);

printf(“z: %d\n”, z);

 

  1. Which of the following is the output generated by the first print statement in the code segmentabove?
    1. result:0
    2. result:1
    3. result:2
    4. None of the

 

  1. Which of the following is the output generated by the second print statement in the code segmentabove?
    1. x + y:13
    2. x + y:15
    3. x + y:14
    4. None of the

 

  1. Which of the following is the output generated by the third print statement in the code segmentabove?
    1. z:15
    2. z:13
    3. z:14
    4. None of the

 

  1. Which of the following statements regarding logical expressions isFALSE?
    1. When attempting to print the result of a logical expression that is true as an integer the resultwill always be 1.
    2. Complementing a condition is one way to potentially remove negative logic from an
    3. A logical expression cannot be used as the control expression of a switch
    4. None of the

 

  1. Whichof the following statements regarding the case label of the switch construct is FALSE?
    1. The constant expression represented by a caselabel cannot contain any mathematical operators.
    2. The caselabel represents an integral type that may be compared to the result of the control expression.
    3. No two switch caselabels can represent the same constant expression value.
    4. None of the

 

Use the code segment below for problems 6 – 7

int x = 9; int y = 8; int z = 4;

 

int result;

 

result = x > y > z;

 

result += ++x % z > –y % z; result += ++x % z > –y % z;

printf(“result 1: %d\n”, result); result = x++ != y + ++z;

result += ++x != y + z++; result += x && y && z % 2 == 0;

 

printf(“result 2: %d\n”, result);

 

  1. Which of the following is the output generated by the first print statement in the code segmentabove?

 

  1. result 1:1
  2. result 1:2
  3. result 1:0
  4. None of the

 

 

  1. Which of the following is the output generated by the second print statement in the code segmentabove?

 

  1. result 2:0
  2. result 2:1
  3. result 2:2
  4. None of the

 

 

  1. Which of the following statements regarding selection constructs isFALSE?
    1. The conditional expression has three operands and a two-token
    2. The short-circuit method of evaluating logical expressions is not applicable to the logical expressionsof an if/else if/else
    3. The logical expression of an if/elseconstruct requires enclosure in parentheses.
    4. None of the

 

  1. Which of the following statements regarding repetitive processes isTRUE?
    1. In an event-controlled process we know the total number of times that the actions found inside the body of the loop will be executed.
    2. According to course standards the use of the forloop must be limited to event-controlled processes.
    3. While the concept of recursion is not limited to pretest or post-test it is a poor design to use itwith event-controlled processes.
    4. None of the

 

  1. Which of the following statements regarding looping constructs isFALSE?
    1. Immediately following the update action of a forloop will be the evaluation of the loop control expression.
    2. The initialization of the loop control variable must take place outside the body of a do-while
    3. In a whileloop the number of times the loop control expression is evaluated is one more than the number of times the loop will
    4. None of the

 

Use the code segment below for problems 11 – 12

  • int w =0;
  • int x = 5; 7 int y =10;

8 int z = 0; 9

10 if(w && x || y && z) 11 {

12 w = 1;

13 }

14 else if(!w && !x || !y && !z) 15 {

16 x = 1;

17 }

18 else if(!w || !x && !y || !z) 19 {

20 y = 1;

21 }

22 else

23 {

24 z = 1;

25 }

26

27 printf(“w: %d x: %d y: %d z: %d\n”, w, x, y, z);

 

  1. Which of the following is the output generated by the print statement in the code segment above? A) w: 1 x: 5 y: 10 z:0
  2. B) w: 0 x: 5 y: 1 z: 0
  3. C) w: 0 x: 5 y: 10 z: 1
  4. D) None of the above.

 

  1. Which of the following logical expressions from the code segment above arecomplements?
    1. The logical expressions on line #10 and line #14 are
    2. The logical expressions on line #10 and line #18 are
    3. The logical expressions on line #14 and line #18 are
    4. None of the

 

  1. Which of the following statements regarding the forloop construct is TRUE?
    1. Theuse of either x++ or ++x are interchangeable as the update expression of a for loop to increment the loop control variable by one.
    2. It is not possible to update the loop control variable of a forloop inside of its
    3. The compiler as used on our server this semester will permit a variable to be declared and initializedin the first expression of a for
    4. None of the

 

  1. Which of the following would NOT be a violation of course programmingstandards?
    1. Making use of a forloop but not using all three of its expressions.
    2. The use of breakto terminate a loop.
    3. Allowing a single user-defined function to terminate in multiple places through the use ofmultiple

return statements.

  1. None of the

 

Use the program below for problems 15 – 17

#include<stdio.h>

 

int leap1(int); int leap2(int); int leap3(int);

 

int main()

{

int leap;

 

leap = leap1(1900) + leap1(2000) + leap1(2020); printf(“leap 1: %d\n”, leap);

leap = leap2(1900) + leap2(2000) + leap2(2020); printf(“leap 2: %d\n”, leap);

leap = leap3(1900) + leap3(2000) + leap3(2020); printf(“leap 3: %d\n”, leap);

return(0);

}

 

int leap1(int year)

{

return(year % 4 ? 0 : (!(year % 100) && !(year % 400) ? 1 : 0));

}

 

int leap2(int year)

{

return(!(year % 100) && !(year % 400) ? 1 : (!(year % 4) ? 1 : 0));

}

 

int leap3(int year)

{

return(year % 400 ? (year % 100 ? (year % 4 ? 0 : 1) : 0) : 1);

}

 

  1. Which of the following is the output generated by the first print statement in the programabove?

 

  1. leap 1:0
  2. leap 1:1
  3. leap 1:2
  4. None of the

 

 

  1. Which of the following is the output generated by the second print statement in the programabove?

 

  1. leap 2:1
  2. leap 2:2
  3. leap 2:3
  4. None of the

 

 

  1. Which of the following is the output generated by the third print statement in the programabove?

 

  1. leap 3:0
  2. leap 3:1
  3. leap 3:2
  4. None of the