You are on page 1of 18

Basic “C” Programming Questions – Folder 37121

Note: Correct answers are marked with “ * * ” Folder 37121

1. Which of the following are true of C? (Select multiple answers)

a. It is an high level programming language.


b. The source code can be executed on any machine.
c. It is designed specifically for scientific application.
d. It is designed to manipulate internal storage areas easily **

2. C was originally used to develop the______________operating system.

a. DOS
b. Windows
c. UNIX **

3. Which of the following is an invalid identifier name? (Select one answer)

a. Counter.
b. Index_1
c. 1Counter **

4. Which of the following is a valid identifier name? (Select one answer)

a. boys&girls
b. _mycounter.
c. 22455 **

5. Execution of a C program begins at the ______________ ( ) functions.

a. Hello
b. WinMain
c. main **

6. Match the following with their purpose in C programming

B 1. braces { } A. Moves to the cursor to the beginning of the next line.

D 2. parentheses ( ) B. Delimit a block of processing statements.

A 3. asterisk * C. Marks where the statement ends.

C 4. semi colon D. Enclose function call parameters (or arguments)


7. Which of the following delimit the beginning of a comment in C programs? (Select
one answer)

a. */
b. {
c. /* **
d. “

8. What would happen if the semicolon after the variable definition statement were
omitted? (Select one answer)
int index
index = 13;

a. The program crashes when executed.


b. A compiler error occurs. **
c. Nothing, The program runs just fine.

9. Which of the following are considered good programming form in C? (Select


multiple answers)

a. The Opening and Closing braces are aligned with the main()
function.
b. The printf() function are aligned with main() function.
c. Blank spaces align character strings as they will be aligned in the
output.
d. Statements within the main () function statement block are
intended three spaces **

10. Match the type of processing on the left with its corresponding construct on the
right:

C 1. Iterative Processing. A. if / else


A 2. Conditional Branching. B. branches and switches.
B 3. Alternative Processing. C. loops.

11. How many lines of output does this program display? (Select one answer)

a. 5 1. main( )
b. 6 ** 2. {
c. 7 3. int count;
4. count = 0;
5. while (count < 6) {
6. printf("The value of count
is %d\n",count);
7. count = count + 1;
8. }
9. }
12. If a program does not increment the count value how many times is the loop
executed? (Select one answer)

a. 0
b. 6
c. An Infine Number Of Times **

13. If i were assigned a value of 125 would this program produce output? (Select one
answer)
1. main( )
a. Yes ** 2. {
b. No 3. int i;

4. i = 0
5. do {
6. printf("The value of i
is now %d\n",i);
7. i = i+1
8. } while (i < 5);
9. }

14. Place the following in sequence to reflect the execution of a for loop.

Step 1. C A. The test condition is evaluated.

Step 2. A B. The Loop repeats, Starting with Step 2.

Step 3. D C. The initial operation is performed.

Step 4. E D. If the test condition is true, the loop body executes

Step 5. B E. The end-of-loop operation is performed.

15. Match the variable data type on the left with its description on the right.

Char 1. C A. Stores a number that does not have a decimal number

int 2. A B. Similar to float but specifies more precision.

Float 3. D C. The smallest data type used to store sigle character.

double 4. B D. Store values containing decimal places.

16. Match the data type on the left with its characteristic on the right.

C 1. Double Float A. Contains decimal places,may give up accuracy due to


rounding.
A 2. Float B. Occupies only 1byte or 8 bits of information.
D 3. int C. Uses most memory and provides the most precision.
B 4. char D. Does not return decimal values.
17. In line 7, the cast operator (int) casts the floating point variable x to an integer.
What is the value of the integer x? (Select one answer)

1. main( )
a. 17.1
2. {
b. 4
3. int a = 2;
c. 17 **
4. float x = 17.1, y = 8.95, z;
5. char c;

6. c = (char)a + (char)x;
7. c = (char)(a + (int)x);
8. c = (char)(a + x);
9. c = a + x;

10. z = (float)((int)x * (int)y);


11. z = (float)((int)(x * y));
12. z = x * y;

18. Review the code opposite. What is the value of z after line 6 executes? (Select
one answer)
1. main( )
a. – 13 ** 2. {
b. 11 3. int x = 11,y = 11,z = 11;
c. false 4. char a = 40,b = 40,c = 40;
5. float r = 12.987,s = 12.987,t =
12.987;
6. if (x == y) z = -13;
7. if (x > z) a = 'A';
8. if (!(x > z)) a = 'B';
9. if (b <= c) r = 0.0;
10. if (r != s) t = c/2;
11. if (x = (r != s)) z = 1000;
12. if (x = y) z = 222;
13. if (x != 0) z = 333;
14. if (x) z = 444;

19. Which of the following are comparison operators? (Select multiple answers)

a. >= **
b. <= **
c. !=
d. = **

20. Line 11 is different from line 10. What is the value of r after line 11? (Select one
answer)

1. main( )
2. {
3. int x = 11,y = 11,z = 11;
4. char a = 40,b = 40,c = 40;
Continue…
a. 14.56 5. float r = 12.987,s = 12.987,t = 12.987;
b. 12 **
c. 14.56 6. x = y = z = 77;
d. True 7. if ((x == y) && (x == 77)) z = 33;
e. FALSE 8. if ((x > y) || (z > 12)) z = 22;
9. if (x && y && z) z = 11;
10. if ((x = 1) && (y = 2) && (z = 3)) r =
12.00;
11. if ((x == 2) && (y = 3) && (z = 4)) r =
14.56;

Folder 37122

21. A variable declared outside of the main( ) function is known as a(n) ______________
variable.

a. Local
b. Static
c. Global **

22. Which of the following locations would you choose to declare a local variable
available to the main( ) function? (Select one answer)

a. Before the main() function .


b. Before the first delimiting brace of the main() function.
c. After the first delimiting brace of the main() function. **
d. Before the last delimiting brace of the main() function.

23. The executable statement of a user-defined function may be located later


in the calling program or in a user ___________________.

a. Class
b. Function
c. Library **

24. Which of the following statements accurately describe user-defined functions?


(Select multiple answers)

a. They are delimited with curly braces. **


b. They each contain a main() function.
c. They must be declared as a variable.
d. Their statement are excuted in sequence. **
25. Which one of the following statements would call a function named display and
pass it a variable named unit1. (Select one answer)

a. Unit1(display)
b. Display(Unit1) **
c. Display() Unit1
d. Unit1. Display;
26. “C” has ______ number of standard keywords in its collection. (Select one answer)

a. 35
b. 32 **
c. 38

27. Which one of the following statements must be true of a variable received by a
function? (Select one answer)

a. It must be of the same data type as the variable passed in the function call.
b. It must be declared before the delimiting braces of the receiving
function* *
c. It must be global variable.
d. It must be declared by the calling function.

28. Which one of the following parts of a program executes after the closing brace of
a called function? (Select one answer)

a. It must be of the same data type as the variable passed in the function
call.
b. It must be declared before the delimiting braces of the receiving
function* *
c. It must be global variable.

29. Which one of the following parts of a program executes after the closing brace of
a called function? (Select one answer)

a. The first line of the main() function.


b. The first line of the calling function.
c. The next line of the called function.
d. The next line after the function call **

30. Which of the following statements accurately describes global variables? (Select
multiple answers)

a. They are declared within the main () function.


b. They are available to any function in the program once they are defined.
c. They are defined with the global keyword.
d. They are declared outside any braces **
31. The scope of a variable is delimited by the_____________within which it is declared.

a. Parentheses.
b. Braces. **
c. Semicolon.

32. Which of the following statements accurately describe local variables? (Select
multiple answers)

a. They are know automatic variables


b. They are declared within the statement block
c. They exist only while the statement block is executing.
d. They are available to any function onces they are defined.

33. You can prevent a local variable from being deleted when a function terminates
by using the ___________ keyword in the variable declaration.

a. Automatic
b. Static. **
c. Current.

34. A storage area within the CPU that provides high speed access to its contents is
known as a(n) ____________________.

a. Controller
b. Register. **
c. ALU.

35. Which of the following statements accurately describe duplicate variable names?
(Select multiple answers)

a. A local variable may have the same name as a variable in another


function.
b. A local variable may have the same name as a global variable.
c. A local variable is unavailable to a function when a global variable has the
same name.
d. A local variable may be used to change the values contained by other
variables with the same name.

36. Which of the following statements accurately describe function prototypes?


(Select multiple answers)

a. They are models of functions.


b. They cause compiler to perform error checking. * *
c. They define whether the function will return a value.
d. They replace the function header.
37. The only difference between a prototype definition and a function header
is the _________________that terminates a prototype definition.

a. Parentheses.
b. Semicolon. **
c. Braces.

38. Which one of the following statements accurately describes the #include
directive? (Select one answer)

a. It define the library prototype one at a time.


b. It define prototype for user-define functions.
c. It instructs the preprocessor to include the contents of a header
file when the program is prepared for execution. **
d. It terminates with an semicolon.

39. Which of the following statements accurately describe the classic style of
function definition? (Select multiple answers)

a. The return data type of an non integer function must be declared


before the function is called.
b. The return data type of an non integer function must be defined in a
prototype.
c. The data type of a receiving variable must be defined before the
functions opening brace.
d. The data type of the receiving variable may be specified in the function
header.

40. One of the advantages of using the modern style of function definition
is that you allow the compiler to perform __________________.

a. Debugging.
b. Error Checking **
c. Conversion.

41. A recursive function is a function that calls ____________________.

a. Program
b. ItSelf **
c. Function.

42. Which of the following statements accurately describe recursive functions?


(Select multiple answers)

a. They can only pass integer values.


b. They allow statements defined within them to be executed
repeatedly.
c. They can generate several copies of themselves.
d. They call the main() function.
43. The temporary storage area that contains variables used within a recursive
function is known as the ______________________.

a. Address.
b. STACKS **
c. Pointers.

44. Which of the following statements accurately describe the stack? (Select multiple
answers)

a. It expands as needed to contain variables needed by a recursive


function.
b. It decrements variables passed to it.
c. It displays variables upon demand.
d. It empties itself of variables that are no longer needed.

45. When two functions call each other, or three or more functions call each other in
a circle, this is known as _____________________recursion.

a. Direct.
b. Indirect **
c. Circular.

46. “C” programming was developed for ___________________________.

a. Windows Application Development


b. System Development **
c. Graphical Development.

47. The statement used to create constants and macros for use in a program is know
as a(n)______________________________.

a. Macros
b. Define Directives **
c. Runtime Macros.

48. Transforming a C program into executable code is a three-step process. Match


each step to with its description.

C 1. Preprocessing A. Produces Object Code.

A 2. Compiling B. Produces Executable Code.

B 3. Linking C. Copies Specified header files into the program and


resolves #define directives.

49. You can specify a name that will stand for another value when a program is
executed by defining a(n)________________________.
a. Macros
b. Constant **
c. Identifier.

50. “C” is an __________________kind of programming language.

a. Object Programming
b. Modular/Prcedural **
c. Component Oriented.
51. Which of the following statements accurately describe the advantages of using
symbolic constants? (Select multiple answers)

a. They allow values to represent meaningful names.


b. They automatically increment control variables.
c. They eliminate the need to use function.
d. They simplify editing values that are used repeatedly by the
program * *

52. Which one of the following statements accurately describes the use of
parentheses in macros? (Select one answer)

a. They allow the macros to correctly evaluate mathematical


expression.
b. They allow the macros to define the data type of received values.
c. They allow the macros to pass arguments to call functions.
d. They allow statements within them be executed repeatedly.

53. Which of the following types of errors can result from misuse or omission of
parentheses in macros? (Select multiple answers)

a. In Correct values are assigned.


b. Mathematical expressions are not evaluated.
c. Mathematical expressions incorrectly evaluated.
d. Variables are erased.

54. To define a group of constants that corresponds to a sequence of number values,


you can declare a(n) __________________________.

a. Enumeration Variables. **
b. Global Variables.
c. Local Variables.

55. Which of the following statements accurately describe enumeration variables?


(Select multiple answers)

a. They are integer variables **


b. They specify a sequence of symbolic name and constant values.
c. They are declared using #define directive
d. They allow the programmer to specify what integer value to assign
to each symbolic name.

56. By default, the integer values assigned to symbolic names in an enumeration


variable begin with the number____________

a. 0 **
b. 32.
c. 20.

57. In relation to "C” programming, ANSI is an _______________________.

a. Standard **
b. Concept.
c. Extension.

58. A group of characters considered as a single unit of data is known as


a(n)_________.

a. String **
b. Array.
c. Enumeration.

59. Which one of the following pieces of information is specified by the subscript at
the end of a character string definition? (Select one answer)

a. The contents of the string.


b. The number of data characters in the string
c. The number of data characters in the string minus one.
d. The number of data characters in the string plus one.

60. The last character in any character string is a(n)____________________ character

a. EOF.
b. BOF
c. NULL.

61. Which of the following pieces of information are specified by the parameters of
the strcpy( ) function? (Select multiple answers)

a. The source string to be copied.


b. The length of the source string.
c. The target string for the copy operation.
d. The length of target string.

62. Which of the following statements accurately describe the strcmp( ) function?
(Select multiple answers)

a. It accepts two parameters.


b. It compares strings.
c. It returns one of the two values.
d. It is a library defined funtion.

63. Which of the following statements accurately describe the parameters of the
strcat( ) function? (Select multiple answers)

a. The first parameter specifies the string that will have a new string
added to it.
b. The first parameter specifies the string that will be added to another.
c. The second parameter the string that will have a new string added to it.
d. The second parameter specifies the string that will be added to
other.

64. Which of the following statements accurately describe objects in an array?


(Select multiple answers)

a. They occupy contiguous area in the computer memory.


b. They all have the same size and data type
c. They each have their own variable name.
d. They can be accessed by referring to their position in the array.

65. To specify the third element of the array ingredients[12] you would write
________________________

a. Ingredients.12
b. Ingredients[3]
c. Ingredients[2] **

66. Unlike a character array, an integer array does not require a terminating
___________________________

a. Number
b. Null
c. Character **

67. Which one of the following actions will result when an array declaration does not
specify the array length? (Select one answer)

a. The compiler will not create the array correctly.


b. The compiler will create the array with one data element.
c. The compiler will allocate enough space in the array for any data
that is assigned to it.
d. The compiler will create an array of 255 data elements.

68. By declaring an array before the main( ) method, you create a(n) _____________

a. Smart Array
b. Local Array
c. Global Array **

69. Which of the following statements accurately describe two-dimensional arrays?


(Select multiple answers)

a. They require two subscripts to define their size.


b. Their column subscript is listed first, and their row subscript second.
c. They contain multiple rows and column.
d. They must contain equal number of rows and column

70. Loading data into a two dimensional array requires two__________________________


for loops.

a. Elements
b. Arrays
c. Nested **

71. How many subscripts are required for each assignment statement that loads data
into a two-dimensional array element? __________________

a. 4
b. 6
c. 2 **

72. Which of the following elements must be specified in the function header
parameters for a function that receives an array? (Select multiple answers)

a. The name of the array passed by the calling function.


b. The data type of the array.
c. An identifier that the received data is contained in an array.
d. The size of an array.

73. Which of the following statements accurately describe array data passed
between functions? (Select multiple answers)

a. The data is contained in independent local copies within each function.


b. The data is local to each function unless the array is declared before the
main ( ) method.
c. The data is contained in a single copy of the array.
d. The data is changed in one function is reflected in all other
functions that accesst the array.
74. The address of the variable or stack location is access by an
_____________________.

a. Macro
b. Address operator.
c. Pointers **

75. The declaration of local variable in an function is also called as


_____________________ storage.

a. Local
b. Automatic Storage **
c. Global

76. _______________ is an storage class.

a. void
b. static, auto, register * *
c. extern

77. User defined data typed can be made using ______________.

a. int abc;
b. typedef int OurInt **
c. char str[10];

78. Conditional Operators use the ___________ and ______________ operators in its
expression.

a. ^ ^
b. ? : **
c. % ;

79. Difference between the while…, and do…while is that ________________________

a. Both are decisive statements


b. While loops are higher precedings then do..while loop.
c. While loop is entry check, and do while is exit check * *
d. Programming practices recommend while loop

80. Operators can be described as prefix or postfix operators depending upon


whether they come before the ________________ or after the ______________

a. Value Item
b. ?:
c. l value , l value **
d. Increment and Decrement.

81. By using the _____________ operator it is possible to initialize and increment


/decrement other variables in addition to the loop control variables.

a. Conon :
b. Question ?
c. Comma , **
d. semicolon ;

82. What does the following expression evaluate, by omitting all the three
expressions it is possible to set up an ___________________

a. For Loop
b. While Loop
c. Infinite Loop **

83. In a ____________ and a ___________ loops all statement within the loops will be
executed while the conditional expression is true.

a. While, for
b. Dowhile and for
c. While do… while **

84. A __________ loop is generalized while loop and may contain up to _______
expressions.

a. While , 4
b. For, 2 **
c. Do…while , 2

85. A __________ and ________ statement in conjunction with an if statement use to


terminate a loop and branch a loop.

a. Printf(), Scanf()
b. break, contine **
c. for, while

86. A __________ statement permits unconditional branching and its use should be
avoided if possible.

a. break
b. goto **
c. for loop

87. A __________ should be written as a self-contained unit that represents


programmed activity

a. declaration
b. Function **
c. Main()
88. When calling a function the list of constants or variables after the function name
is known as the __________________________list

a. Formal Parameter
b. Actual Parameter **
c. Local Parameter.

89. ____________________ occurs automatically when either the actual or formal


parameters do not have the same type or the function type does not match the return
type.

a. Format Conversion.
b. Actual Conversion **
c. Actual Conversion.

90. The storage class ________, _________,__________ and _________ can be assigned to
variables.

a. Get(), Put(), puts(), gets()


b. Static, Auto, Exter, Register **
c. Declarations, statements, function, declaration.

91. There is no prototype for main declared by the compiler, therefore, it is


permissible to use ___________ or _____________________, implying no return value and no
parameter.

a. Try, Catch
b. main ( ), void main ( ) **
c. #include, #define.

92. A Set of ______________ macros predefined and must not be redefined or


undefined.

a. Standard
b. 5 **
c. User defined

93. Both _______________ and _______________ contains a range of useful mathematical


functions which may be included in parenthesized macros or used in the same manner
as other functions.

a. <math.h> <stio.h>
b. <math.h> <conio.h>
c. <math.h> <stdlib.h> **

94. Array parameters are passed by _______________, therefore, any changes to the
parameter will result in corresponding changes to the arguments.
a. Copy or Value
b. Self.
c. Reference **

95. A ________________ may be given a tag or name, that can be used to declare a
variable of the same structure type.

a. Enumeration
b. Structure **
c. Union.
96. A _____________ can have more then ___________ dimensions.

a. Structure, One
b. Array, One **
c. Union, Two

97. A storage allocation is through the function ______ and _____ found in ________

a. New, delete, <iostream.h>


b. malloc, calloc, <stdlib.h> **
c. GetDC(), ReleaseDC(), <windows.h>

98. The indirect operator _______ is used to specify the contents of the memory being
pointed at by the pointed variable.

a. &
b. * **
c. 

99. A _____________ is an identifier that stores an address of an item of data.

a. Array Address
b. Pointer **
c. Structure.

You might also like