1 attachmentsSlide 1 of 1attachment_1attachment_1
Unformatted Attachment Preview
CSCE A201 Midterm #1 v2
This exam is worth a total of 100 points. The exam is open book and open notes. You
can use a calculator or a computer but should be your own work. Show your work or
thought processes. You can insert your answers into this document and upload your final
answers or upload your answers in a separate document(s) that are compressed into a
single zip file.
1) 20 points. Short Answer.
a) What could go wrong with the code:
if (strvar == “hello”)
b) Add parenthesis to the expression below to match the order that will be used in C
when evaluating the expression.
3 + 5 % 2 * 10
c) A variable of type char is used to store a character. Why does C allow you to
assign a number to a char variable, for example, char c = 65; ?
d) Fill in the blanks for the program below. The program should calculate the
product of the even integers from 1 to 15 (i.e. 2*4*6*8*10*12*14) and print it.
int product = ________;
for (int i=1; i 0)
value = value + count;
count = count – 2;
printf(“Value: %dn”, value);
3) 20 points. Bugs! Find and fix the bugs in the following code snippets.
a) The following code should output “big” if the input is exactly 100 and “small”
if (value = 100)
b) The following code should keep asking the user to enter a key until the key pressed
is ‘Y’ or ‘N’, at which point the loop should exit.
printf(“Try again? Press Y or N.n”);
} while ((c!=’Y’) || (c!=’N’));
c) The following should input 5 numbers into the array.
for (int i = 1; i
Purchase answer to see full
Explanation & Answer:
User generated content is uploaded by users for the purposes of learning and should be used following Studypool’s honor code & terms of service.