CSIS 123 Practice Test I

Instructions: There are 30 questions on this test. It is written in a style very similar to the REAL Exam #1. Choose the best answer from among those given. Click the GRADE button on the bottom of the form when you want the exam graded.

Note: You can practice this test as many times as you desire; the system will cook you up a fresh batch of questions each time you access this page.

Your Name: @ 3.14.130.24

1. To print a FLOAT with a field width of 10 and 2 digits to the right of the decimal point, what PRINTF format specifier should be used?

a) "%8.2lf"
b) "%10.2f"
c) "%12.2d"
d) None of the above

2. What will the output of the following code be?

double Zeta; // Holds ratio of alpha/w(nat)

Zeta = 0.707107; // Less than critically damped system
printf("Damping ratio = %10.1lf\n", Zeta );

a) Damping ratio = 0.707107
b) Damping ratio = 0.707
c) Damping ratio = 0.7
d) None of these

3. What will be in variable 'A' after executing the following code?

int a,b;

b = 24;
a = ++b + 10;

a) 34
b) 35
c) 33
d) None of the above

4. In order to solve a problem using a programming language, what must be done first?

a) Determine an algorithm that solves the problem
b) Write computer source code instructions
c) Define the problem
d) None of the above

5. What type of data must be in variable A below?

printf("A = %d now.\n", a );

a) int
b) char
c) float
d) double

6. What is object code?

a) Incomplete machine code
b) Instructions typed in by the programmer
c) The result of the C preprocessor's operation
d) None of the above

7. What is the result of evaluating the following expression?

22/7. + 5/3

a) 4.142857...
b) 4.809523...
c) 5
d) None of the above

8. What are the objects in programming?

a) The computer's instructions
b) The data
c) The constants
d) None of the above

9. Which of these lists the products of a C compilation session in correct order?

a) Assembly code - Source code - Object code - Machine code
b) Machine code - Object code - Source code - Assembly code
c) Source code - Assembly code - Object code - Machine code
d) None of these

10. Every C statement ends with what character?

a) ','
b) '*'
c) ';'
d) None of the above

11. In C, a logical AND is indicated by what operator?

a) &&
b) ||
c) ++
d) None of the above

12. If A=2 upon entry into the code below, what will be output?

switch (a)
     {
     case 1: printf("Unlocking door.");
         break;

     case 2: printf("Checking back door.");
         break;

     case 3: printf("Locking door.");
         break;

     default: printf("Unknown command.");
         break;
     }

a) Checking back door
b) Unlocking door
c) Locking door
d) Unknown command

13. What conditions must be present for the fragment below to print the message "B is too small?"

if (a<20)
     printf("Too Small.");
     else
     if (b >= 10)
         printf("Everything is OK.");
         else
         printf("B is too small.");

a) (a < 20)
b) (a > 20) and (b >= 10)
c) (a>=20) and (b < 10)
d) None of the above

14. When is a C expression considered to be 'true?'

a) When it is non-zero
b) When it is zero
c) Whenever it is not false
d) None of the above

15. For the code below to print the message "OK", what conditions are needed?

if (a<20) && (b == 25)
     printf("OK");

a) A must be more than 20, OR B must be equal to 25
b) Either A must be less than 20, OR B must be not equal to 25
c) A must be less than 20, AND B must be equal to 25
d) None of the above

16. If A=4 upon entry into the code below, what will be output?

switch (a)
     {
     case 1: printf("Unlocking door.");
         break;

     case 2: printf("Checking back door.");
         break;

     case 3: printf("Locking door.");
         break;

     default: printf("Unknown command.");
         break;
     }

a) Checking back door
b) Unlocking door
c) Locking door
d) Unknown command

17. Given that A=25 and B=10, what will the output of the fragment below be?

if (a<20)
     printf("Too Small.");
     else
     if (b >= 10)
         printf("Everything is OK.");
         else
         printf("B is too small.");

a) Too Small.
b) B is too small.
c) Everything is OK.
d) None of the above

18. A 'for' loop is written as follows:

for(i=0 ; i<25 ; i++)
     printf("Testing %d\n", i);

What will the highest and lowest printed values of 'i' be?

a) 1 and 25
b) 0 and 26
c) 0 and 24
d) None of the above

19. A 'for' loop makes its test:

a) At the top of the loop
b) At the bottom of the loop
c) Either the top or the bottom of the loop, as the programmer desires
d) None of the above

20. What will be the output of the following FOR loop?

for(i=0 ; i<5 ; i++)
     {
     if (i==2) continue;
     printf("%d", i);
     }

a) 1 2 3 4 5
b) 0 1 2 3 4
c) 0 1 3 4
d) None of the above

21. What is the effect of the break statement?

a) The body of a running loop is repeated
b) A running loop is exited, execution resumes at next statement after loop
c) The loop counter is decremented by 1
d) None of the above

22. What output will be produced by the DO loop below?

int i=2;

do  {
     i++;
     if (i==7) continue;
     printf("%d", i);
     }
     while(i<10);

a) 3 4 5 6 7 8 9
b) 2 3 4 5 6 7 8
c) 3 4 5 6 8 9 10
d) None of the above

23. What output will be produced by the DO loop below?

int i=0;

do  {
     i++;
     printf("%d", i);
     }
     while(i<5);

a) 1 2 3 4 5
b) 0 1 2 3 4
c) 0 1 2 3
d) None of the above

24. According to the way "MyFunct" is being used below, what is its prototype?

int x,y;
//
//Program logic to fill x and y with data here
//

MyFunct(x, y);

a) int MyFunct(int, float);
b) void MyFunct(int, int);
c) float MyFunct(int, double);
d) None of these

25. A certain function is written as follows:

MyFunct(int x)
{
return(x * x);
}
What is the data type returned by this function?

a) char
b) int
c) float
d) None of the above

26. How many passes does the C compiler make through the source code?

a) 1
b) 2
c) 3
d) None of the above

27. When do C functions need to be prototyped in single-source-file projects?

a) Prototyping is always optional in C as long as a single file contains all the source code.
b) When functions are called before they are defined (i.e., function 'below' use in listing.)
c) Prototyping is always required, regardless of where the functions are used.
d) None of the above

28. What is the default data type returned by C functions?

a) int
b) float
c) void
d) None of the above

29. A certain function has the following prototype:

float MyFunct(int x, float z);

Which statement below correctly calls this function? Assume that A and B are type INT, and C is type FLOAT.

a) MyFunct( a, b);
b) a = MyFunct( 0, a);
c) c = MyFunct( a, 1.41459 );
d) None of the above

30. What is wrong with the function below?

float MyFunct(int x, float z)
{
float x2;

x2 = z*z + x;
}

a) Function defined as type FLOAT but fails to return a value
b) A semicolon is required on the first line 'float MyFunct(int x, float z);'
c) The function is returning the wrong data type (INT)
d) None of the above

NOTE

When you take exam #1, you will also have to write some code. Make sure you know how to punctuate PRINTF statements, write IF-ELSE statements, write FOR/DO/WHILE loops, and work with functions and their prototypes.


Press GRADE EXAM button to see how you did!

Grade Exam!