COMP215 Practice Final Exam

Instructions: There are 50 questions on this test. It is written in a style very similar to the REAL final exam. 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: @ 18.118.226.105

1. Given the following declaration:

int Values[25];

Which expression below is equivalent to: Values?

a) &Values[0]
b) Values[0]
c) Values[-1]
d) None of these

2. Given the following declaration:

int Values[25];

Which expression below is equivalent to: &Values[0]?

a) Values[0]
b) Values[-1]
c) Values
d) None of these

3. Which declaration below would be correct to make "pVar" a pointer to int type?

a) int pVar;
b) int* pVar;
c) int &pVar;
d) None of these

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

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

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

5. How are comments marked in C++?

a) With the ';' character
b) With either '//' (start of line) or '/* .. */'
c) With the '++' sequence
d) None of the above

6. 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

7. 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

8. 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

9. 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

10. 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

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

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

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

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

13. 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

14. 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

15. What is the meaning of the following declaration?

float* pVar;

a) pVar is a pointer to data of type FLOAT
b) pVar is a floating point variable
c) pVar is meant to have an initial value of zero
d) None of these

16. 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

17. 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

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

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

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

19. Given the declarations:

char szData[64];
int i;

i=314;

Supposed that we wish to place a text message into szData that shows the value in variable i. Which of the statements below would accomplish this?

a) strcpy( szData , "i = %d", i);
b) sprintf( szData , "i = %d" , i );
c) strcat( szData , i , "i = %d" );
d) None of these

20. The data being manipulated by a program is also known as:

a) The objects
b) The algorithm
c) The flow
d) None of the above

21. 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

22. 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

23. Given the following declaration:

int Values[4]={1,2,3,4};

What value will be returned if the expression "*Values" is evaluated?

a) 2
b) 1
c) &Values[0]
d) 4
e) None of these

24. What is the data type of the following expression:

22/7. + 3.14

a) Int
b) Float
c) Char
d) None of the above

25. What information must be passed to the STRCPY() library routine?

a) The length of each string, and the address of each string.
b) The address of each string.
c) The length of one of the strings.
d) None of these

26. 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

27. 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

28. 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

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

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

30. What character code is used to end all strings in C?

a) '\n'
b) '\0'
c) '\7'
d) None of these

31. Which standard stream below could be used to talk to a printer?

a) stdout
b) stdprn
c) stderr
d) stdaux
e) None of the above

32. If the character sequence CR-LF ('\r' '\n') is encountered while reading a text file, what character sequence will result on the C side of the interface?

a) '\r'
b) '\r' '\n'
c) '\0' (NUL)
d) None of the above

33. Which of these is a disadvantage of Stroked (Vector) fonts?

a) A large amount of memory is required
b) Only one color of text can be displayed
c) Rendering is a complex and slow process
d) None of the above

34. Which operator is used to access the member elements of a structure?

a) "*"
b) "."
c) "&"
d) None of these

35. What happens when an object is instantiated?

a) The object is deleted or removed from memory
b) A pointer to the object is created
c) The object is dereferenced
d) None of these

36. Which standard stream below could be used to talk to the video display?

a) stdprn
b) stderr
c) stdout
d) stdaux
e) None of the above

37. In the Borland Graphic Interface, the coordinates (0,0) represent what?

a) The ULH corner of the video display
b) The URH corner of the video display
c) The center of the video display
d) None of the above

38. What value is returned by the NEW operator when a memory allocation request fails?

a) -1
b) NULL pointer
c) 0xffff
d) None of the above

39. Given the following declaration:

struct Complex
    {
    double re;
    double im;
    };

Complex Values[10];

If a DOUBLE uses 8 memory locations, how much memory is used up?

a) 160
b) 80
c) 40
d) None of these

40. Which of these is a disadvantage of passing structures to functions by value?

a) Two copies of the structure occupy memory during the function's execution
b) Copying the structure is a relatively slow process
c) The function can not modify the original values in the structure
d) All of the above

41. What is a stream?

a) A path of communication between a program and the operating system
b) A method for writing to the video screen
c) A method for checking the contents of variables
d) None of the above

42. What is a structure?

a) A user-defined data type that can contains aggregate data
b) A special type of C pointer that can not be dereferenced directly
c) Another name for a C program
d) None of these

43. Which stream below is normally associated with the keyboard?

a) stdout
b) stderr
c) stdprn
d) stdaux
e) None of the above

44. Which type of font below looks best when shown at different magnification levels on a video screen?

a) Bit-mapped
b) Imaginary
c) Stroked (Vector)
d) None of the above

45. What must be done with open files prior to ending a program?

a) Close them
b) Write the final information into them
c) Check their contents
d) None of the above

46. When programming graphics under the DOS environment, what is typically done first within a program?

a) Close all open files
b) Read and save the current video mode
c) Clear the video screen
d) None of the above

47. Given the following declaration:

struct Complex
    {
    double re;
    double im;
    };

Complex Values[ xx ];

If there are 1732 memory locations free, what is the maximum value that "xx" can have, assuming that a DOUBLE uses 8 memory locations?

a) 216
b) 108
c) 132
d) None of these

48. Which statement below would correctly allocate an array of 500 integers by using the 'NEW' operator?

a) int* Array = new int[500];
b) new int Array[500];
c) Array[500] = new int;
d) None of the above

49. Given the following declaration:

struct Complex
    {
    double re;
    double im;
    };

If a DOUBLE uses 8 memory locations, how much memory is used up?

a) 8 locations
b) 16 locations
c) 0 locations
d) None of these

50. What two pieces of information are needed by 'FOPEN()' ?

a) A drive letter and file mode specifier
b) A filename and file mode specifier
c) A file mode specifier and system password
d) None of the above

I hope you have enjoyed this course!


Press GRADE EXAM button to see how you did!

Grade Exam!