Multiple Choice Questions With Answers – C Programming

 

1. Who invented C Programming Language ?

    a)  James Gosling

    b)  Dennis Ritche

    c)   Rasmus Lerdorf

    d) Bjarne Stroustrup

2. C was developed in __________

    a)  1970    

    b)  1972

    c)   1974

    d) 1976

3. C language is a ________

    a)  Procedural oriented programming language

    b)  General purpose programming language

    c)   Structured programming

    d) All of the above

4. Which of the following is not a valid C variable name?

    a)  int number;

    b)  float rate

    c)   int variable_count     

    d) Int $main

5. A data type is a _______ set of values along with a set of rules for allowed operations

    a)  Infinite

    b)  Finite

    c)   Fixed

    d) Variable

6. A variable is a _________ which is able to hold a representation that denotes a value.

    a)  Container

    b)  Box

    c)   Pack

    d) Carton

7. The C preprocessors are specified with ______ symbol.

    a)  #                                  

    b)  $

    c)   “ ”                                

    d) &

8. The scanf() is a predefined function in _________ header file.

    a)  stdlib.h

    b)  ctype.h

    c)   stdio.h

    d) stdarg.h

9. Header files_____

    a)  Contain function declarations

    b)  Can be included to a program

    c)   End with .h extension

    d) All of these

10. Can programmers create their own header files?

        a)  Yes

        b)  No

11. What is the extension of C source file?

    a)  .txt

    b)  .CS                               

    c)   .CPP                            

    d) .C

12. Which of these can be used for a variable name in C?

    a)  Identifier & keyword

    b)  Identifier                 

    c)   Keyword

    d) None of these

13. Find a correct C keyword

    a)  Float

    b)  Int

    c)   Long

    d) Double

14. Which is not a valid keyword in C?

    a)  For

    b)  While

    c)   do-while

    d) Switch

15. All keywords in C are in _______

    a)  LoweCase letters

    b)  UpperCase letters

    c)   camelCase letters

    d) none of the mentioned

16. How many keywords are there in C language?

    a)  32

    b)  33

    c)   64

    d) 18

17. What is the correct syntax to declare a variable in C?

    a)  data_type variable_name;

    b)  data_type as variable_name;

    c)   variable_name data_type;

    d) variable_name as data_type;

18. Which of the following special symbol allowed in a variable name?

    a)  * (asterisk)

    b)  | (pipeline)

    c)   – (hyphen)

    d) _ (underscore)

19. Which of the following functions must be included in all C programs?

    a)  start()

    b)  system()

    c)   main()

    d) program()

20. In C, an uninitialized variable may have

    a)  null value

    b)  nul string

    c)   garbage value

    d) zero value

21. Which character must be used to end a C statement?

    a)  .  (dot)

    b)  ;  (semicolon)

    c)   :  (colon)

    d)  (single-quote)

22. Which symbol must be used to signal the beginning and ending of code blocks or compound statements?

    a)  { }

    b)  à and ß

    c)   BEGIN and END

    d) ( and )

23. Which of the following is a correct syntax for inserting comments in C program?

    a)  */ comments */

    b)  ** comments **

    c)   /* comments */

    d) { comments }

24. Which escape sequence take the control to next horizontal tabulation position?

    a)  ‘n’

    b)  ‘t’

    c)   ‘’

    d) ‘v’

25. In C programming, which one of the following is string termination character?

    a)  ‘’

    b)  ‘n’

    c)   ‘b’

    d) ‘t

26. The directives for preprocessors begin with

    a)  &

    b)  //

    c)   #

    d)

27. Which operator gives remainder after division?

    a)  / (divide)

    b)  % (modulo)

    c)   ^

    d) ~

28. Which of the following is not the primary constant in C language?

    a)  Integer

    b)  Float

    c)   Union

    d) Character

29. Which are the fundamental data types in C?

    a)  char

    b)  int

    c)   float

    d) All of the above

30. How many byte(s) does a char type take in C?

    a)  1

    b)  2

    c)   3

    d) 4

31. What is the name of “&” operator in C?

    a)  Ampersand

    b)  And

    c)   Address of

    d) None of the above

32. Program execution always starts with

    a)  Main

    b)  Variable

    c)   Include

    d) Case

33. Which C keyword is used to extend the visibility of variables?

    a)  extend

    b)  extends

    c)   extern

    d) auto

34. The range of values in integer data type is

    a)  -32768 to 32767

    b)  -128 to 127

    c)   -128 to 256

    d) None of the above

35. Which is correct with respect to the size of the data types in C?

    a)  char>int>float

    b)  char<int<float

    c)   int<char<float

    d) int<flaot<char

36. For which type, the format specifier “%i” is used?

    a)  int

    b)  char

    c)   float

    d) double

37. Which is the correct format specifier for double type value in C?

    a)  %d

    b)  %f

    c)   %lf

    d) %LF

38. What value is returned to the operating system upon the successful completion of a C program?

    a)  -1

    b)  1

    c)   0

    d) -2

39. Which one of the following is the correct operator to compare two variables?

    a)  :=

    b)  =

    c)   Equal

    d) ==

40. Which one of the following is the operator for logical and?

    a)  &

    b)  &&

    c)   |

    d) |&

41. Which of the following is not a bitwise operator?

    a)  &&

    b)  << 

    c)   ~

    d) ^

42. Which of the following symbol is used for AND operator?

    a)  ||

    b)  &

    c)   &&

    d) $$

43. Which of the following is not logical operator?

    a)  &

    b)  &&

    c)   ||

    d) !

44. The _____ operator is true only when both the operands are true.

    a)  bitwise or

    b)  bitwise and

    c)   logical and

    d) Boolean

45. In C programming, ‘++’ is _________ operator

    a)  Increment

    b)  decrement

    c)   Assigning

    d) overloading

46. Increment (++) and decrement (–) are the ________ operators in C

    a)  Unary

    b)  Binary

    c)   Ternary

    d) None of the above

47. Which operator is used to find the remainder of two numbers in C?

    a)  /

    b) 

    c)   %

    d) //

48. Which of the following is not an arithmetic expression?

    a)  x=10

    b)  x /=10

    c)   x %=10

    d) x !=10

49. Which of the following are valid decision-making statements in C?

    a)  if

    b)  switch

    c)   nested if

    d) All of these

50. Decision making in the C programming language is _____

    a)  Repeating the same statement multiple times

    b)  Executing a set of statements based on some condition

    c)   Providing a name of the block of code

    d) All of these

51. What is the correct syntax of if statement in C program?

    a)  If(condition) {    

}

    b)  If(condition):

    c)   If{[condition]}

    d) None of these

52. The if statement is a conditional statement

    a)  True

    b)  False

53. When the condition of if statement is false, the flow of code will _____

    a)  Go into the if block

    b)  Exit the program

    c)   Continue the code after skipping the if block

    d) None of these

54. Which statement is required to execute a block of code when the condition is false?

    a)  for

    b)  if

    c)   else

    d) All of these

55. The if-else if-else statement in C programming is used

    a)  Create multiple conditional statements

    b)  Return values

    c)   Loop in if-else block

    d) All of these

56. Multiple values of the same variable can be tested using ____

    a)  switch

    b)  for

    c)   Function

    d) All of these

57. Without a break statement in switch what will happen?

    a)  All cases will work properly

    b)  Cases will fall through after matching the first check

    c)   Switch will throw error

    d) All of these

58. When all cases are unmatched which case is matched in a switch statement?

    a)  Default case

    b)  First case

    c)   No case

    d) None of these

59. Loops in C programming are used to______

    a)  Execute a statement based on a condition

    b)  Execute a block of code repeatedly

    c)   Create a variable

    d) None of these

60. Which of the following is not a jump statement?

    a)  break

    b)  Continue

    c)   Escape

    d) Goto

61. What is an example of iteration in C?

    a)  for

    b)  while

    c)   do-while

    d) All of the mentioned

62. Which loop executes the block a specific number of times?

    a)  while loop

    b)  for loop

    c)   d0…while loop

    d) all of these

63. Which of the following parts of the for loop can be eliminated in C?

    a)  initialization

    b)  condition

    c)   increment

    d) All of these

64. When all parts of the for loop are eliminated, what will happen?

    a)  For loop will not work

    b)  Infinite for loop

    c)   Error

    d) None of these

65. Which of the following is an exit controlled loop?

    a)  While

    b)  For

    c)   do-while

    d) None of the above

66.      Which one of the following is a loop construct that will always be executed once?

    a)  for

    b)  while

    c)   switch

    d) do-while

67. When the condition of the do-while loop is false, how many times will it execute the code?

    a)  0

    b)  1

    c)   Infinite

    d) All of these

68. Can a loop be nested in C programming?

    a)  Yes

    b)  No

69. What will happen if the loop condition will never become false?

    a)  Program will throw an error

    b)  Program will loop infinitely

    c)   Loop will not run

    d) None of these

70. Which of the following creates infinite loop:

    a)  for (;;)

    b)  then (;;)

    c)   when (;;)

    d) if (;;)

71. Which of the following is valid syntax for creating a while loop?

    a)  While {

} (condition)

    b)  While(condition){

}

    c)   While{

}

    d) All of these

72. What will you use if you are not intended to get a return value?

    a)  static

    b)  const

    c)   volatile

    d) void

73. How will you print n on the screen?

    a)  printf(“n”);

    b)  echo “ n”;

    c)   printf(‘n’);

    d) printf(“ n”);

74. Which of the following cannot be checked in a switch-case statement?

    a)  Character

    b)  Integer

    c)   Float

    d) Enum

75. What is Array?

    a)  Collection of different type of elements

    b)  Collection of similar type of elements

    c)    None of the above

    d)  Both A and C

76. In C programming, array index always starts from

    a)  0

    b)  1

    c)   2

    d) 3

77. You can access elements of an array by________

    a)  values

    b)  indices

    c)   memory addresses

    d) All of the above

78. Which is the correct syntax to declare an array in C?

    a)  data_type array_name[array_size];

    b)  data_type array_name{array_size};

    c)   data_type array_name[];

    d) all of the above

79. Which of the following correctly declares an array?

    a)  int array[10]

    b)  Int array

    c)   Array {10}

    d) array array [10]

80. How are String represented in memory in C?

    a)  An array of characters

    b)  The object of some class

    c)   Same as other primitive data types

    d) linked List of characters

81. What is the disadvantage of arrays in C?

    a)  The amount of memory to be allocated should be known beforehand

    b)  Elements of an array can be accessed in constant time.

    c)   Elements are stored in contiguous memory blocks.

    d) Multiple other data structures can be implemented using arrays.

82. What is right way to initialize array?

    a)   int num[6] = { 2, 4, 12, 5, 45, 5 };

    b)  int n{} = { 2, 4, 12, 5, 45, 5 };

    c)    int n{6} = { 2, 4, 12 };

    d)  int n(6) = { 2, 4, 12, 5, 45, 5 }

83. Which of these best describes an array?

    a)  A data structure that shows a hierarchical behavior

    b)  Container of objects of similar types

    c)   Arrays are immutable once initialized

    d)  Array is not a data structure

84. What is an Array in C language?

    a)   A group of elements of same data type.

    b)  An array contains more than one element

    c)   Array elements are stored in memory in continuous or contiguous locations.

    d) All the above

85. What are the Types of Arrays?

    a)  int, float, char, double

    b)  struct, enum

    c)   long

    d) All the above

86. What is the maximum number of dimensions an array in C may have?

    a)  2

    b)  8

    c)   16

    d) Theoretically no limit. The only practical limits are memory size and compilers

87. Which of the following is the correct way to declare a multidimensional array in Java?

    a)   int arr[[]];

    b)   int[] arr;

    c)    int[][]arr;

    d) int[[]] arr;

88. What does the following declaration mean?

int (*ptr)[10];

    a)  ptr is an array of 10 integers

    b)  ptr is an pointer to array

    c)   ptr is a pointer to an array of 10 integers

    d)  ptr is array of pointers to 10 integers

89. Array elements are always stored in ________ memory locations.

    a)  Random

    b)  None of the above

    c)   Sequential

    d) Sequential and Random

90. Array is an example of _______ type memory allocation.

    a)   Compile time

    b)  Run time

    c)    Both A and B

    d) None of the above

91. In the below statement, what does the “arr” indicates?

char *arr[20];

    a)  arr is an array of 20 characters

    b)  arr is an array of 20 character pointers

    c)    arr is an array of function

    d) arr is a pointer to an array

92. The parameter passing mechanism for an array is

    a)  call by reference

    b)  call by value

    c)   call by value-result

    d) None of the above

93. If we pass an array as an argument to a function, what actually gets passed?

    a)  Value of elements in array

    b)  First element of the array

    c)   Base address of the array

    d) Address of the last element of array

94. Choose correct statement about Functions in C Language-

    a)  A Function is a group of c statements which can be reused any number of times

    b)  Every Function has a return type

    c)   Every Function may not return a value

    d) All the above

95. What is a function in C?

    a)  User defined data type

    b)  Block of code which can be reused

    c)   Declaration syntax

    d) None of these

96. Which of the below syntax is the correct way of declaring a function?

    a)  return function_name() {

}

    b)  data_type function_name(parameter) {

}

    c)   void function_name ( )

    d) None of these

97. Which keyword is used to return values from function?

    a)  return

    b)  Value

    c)   Switch

    d) All of these

98. In C programming, a function can return

    a)  Single value

    b)  Double value

    c)   Many values

    d) None of these

99. Functions in C can accept multiple parameters. True or False?

    a)  True

    b)  False

100. A function which calls itself is called a ___ function.

    a)  Self Function

    b)   Auto Function

    c)   Recursive Function

    d) Static Function

101. In which header file, sqrt() and pow() functions are defined?

    a)  include.h

    b)  conio.h

    c)   iostream.h

    d) math.h

102. The sqrt() function is used to calculate which value?

    a)  Square

    b)  Square of reverse bits

    c)   Square root

    d) None of these

103. How would you round off a value from 1.66 t0 2.0?

    a)  ceil(1.66)

    b)  floor(1.66)

    c)   roundup(1.66)

    d) roundto(1.66)

104. In which header file, strcpy(), strcat(), strlen() functions are declared ?

    a)  include.h

    b)  string.h

    c)   math.h

    d) conio.h

105. A string is terminated by______

    a)  Newline(‘n’)

    b)  Null(‘’)

    c)   Whitespace

    d) None of the above

106. Which format specifier is used to read and print the string using printf() and scanf() in C?

    a)  %c

    b)  %str

    c)   %p

    d) %s

107. To use the function tolower(), which of the following header file should include

    a)  string.h

    b)  conio.h

    c)   ctype.h

    d) don’t need any header file

108. The keyword used to transfer control from a function back to the calling function is

    a)  switch

    b)  goto

    c)   go back

    d) return.

109. What are the types of functions in C Language?

    a)  Library Functions

    b)  User Defined Functions

    c)   Both Library and User Defined

    d) None of the above

110.   Choose correct statements about C Language Pass By Value.

    a)  Pass By Value copies the variable value in one more memory location

    b)  Pass By Value does not use Pointers

    c)   Pass By Value protects your source or original variables from changes in outside functions or called functions

    d) All the above

111. What is the limit for number of functions in a C Program?

    a)  16

    b)  31

    c)   32

    d) No Limit

112. Every C Program should contain which function?

    a)   printf()

    b)  show()

    c)   scanf()

    d) main()

113. A recursive function in C ____

    a)  Call itself again and again

    b)  Loop over a parameter

    c)   Return multiple values

    d) None of these

114. A C program contains______

    a)  At least one function

    b)  No function

    c)   No value from command line

    d) All of these

115. The string function, strcmp() is used for

    a)  Comparing string

    b)  Copying string

    c)   Pattern matching

    d) Concatenating strings

116. Which function is used to concatenate two strings in C?

    a)  concat()

    b)  cat()

    c)   stringcat()

    d) strcat()

117. Which function is used to compare two strings in C?

    a)  strcmp()

    b)  strcmpi()

    c)   compare()

    d) cmpi()

118. Which function is used to compare two strings with ignoring case in C?

    a)  strcmp()

    b)  strcmpi()

    c)   compare()

    d) cmpi()

119. If the two strings are identical , then strcmp() function returns

    a)   -1

    b)  1

    c)   0

    d) Yes

120. What is the minimum number of functions to be present in a C Program?

    a)  1

    b)  2

    c)   3

    d) 4

121. What characters are allowed in a C function name identifier?

    a)  Alphabets, Numbers, %, $, _

    b)  Alphabets, Numbers, Underscore ( _ )

    c)   Alphabets, Numbers, dollar $

    d) Alphabets, Numbers, %

122. Arguments passed to a function in C language are called ___ arguments.

    a)  Formal arguments

    b)  Actual Arguments

    c)   Definite Arguments

    d) Ideal Arguments

123. Arguments received by a function in C language are called ___ arguments.

    a)  Definite arguments

    b)  Formal arguments

    c)   Actual arguments

    d) Ideal argument

124. Choose a corrects statement about C language function arguments.

    a)  Number of arguments should be same when sending and receiving

    b)  Type of each argument should match exactly

    c)   Order of each argument should be same

    d) All the above

125. Choose a non Library C function below:

    a)  printf()

    b)  scanf()

    c)   fprintf()

    d) printf4()

126. What is the default return value of a C function if not specified explicitly?

    a)  -1

    b)  0

    c)   1

    d) None of the above

127. Uses of function

    a)  Helps to avoid repeating a set of statements many times

    b)  Enhances the logical clarity of the program

    c)   Helps to avoid repeated programming across programs

    d) Makes the debugging task easier

    e)  All of the above

128. The function fprintf is used in a program:

    a)  When too many printf calls have been alrady used in the program

    b)  In place of printf, since printf uses more memory

    c)   When output i to be printed on to a file

    d) All of above

129. A recursive function can be replaced with __ in C language.

    a)  for loop

    b)  while loop

    c)   do while loop

     d) All the above

130.  The default parameter passing mechanism is

    a)  Call by value

    b)  Call by reference

    c)   Call by value result

    d) None of the above

131. Which of these is not a valid parameter passing method in C?

    a)  Call by value

    b)  Call by reference

    c)   Call by pointer

    d) All of these

132. Which of the following is the collection of different data types?

    a)  structure

    b)  string

    c)   array

    d) All of these

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

    a) 

    b) 

    c)   *

    d) .

134. What will be used when terminating a structure

    a)  :

    b)  }

    c)   ;

    d) ;;

135. Which of these is a user-defined data type in C?

    a)  int

    b)  union

    c)   char

    d) All of these

136. “A union can contain data of different data types”. True or False?

    a)  True

    b)  False

137. Which keyword is used to define a union?

    a)  Un

    b)  union

    c)   Union

    d) None of these

138. The size of a union is ___

    a)  Sum of sizes of all members

    b)  Predefined by the compiler

    c)   Equal to size of largest data type

    d) None of these

139. All members of union ____

    a)  Stored in consecutive memory location

    b)  Share same memory location

    c)   Store at different location

    d) All of these

140. The member of union can be accessed using_______ ?

    a)  Dot Operator (.)

    b)  And Operator (&)

    c)   Asterisk Operator (*)

    d) Right Shift Operator (>)

141. In which case union is better than structure?

    a)  Less memory is available

    b)  Fasrter compilation is required

    c)   When functions are included

    d) None of these

142. A pointer is

    a)  A variable that stores address of an instruction

    b)  A variable that stores address of other variable

    c)   A keyword used to create variables

    d) None of these

143.  A pointer is a variable, which holds ___________

    a)  Memory address

    b)  Files

    c)   Int variable

    d) Char variable

144. The operator used for dereferencing or indirection is _______

    a)  *

    b)  &

    c)   à

    d) à>

145. What is wild pointer?

    a)  Pointer which is wild in nature

    b)  Pointer which has no value.

    c)   Pointer which is not initialized

    d) None

146. ______ is a pointer that occurs at the time when the object is de-allocated from memory without modifying the value of the pointer.

    a)  Dangling pointer

    b)  Wild pointer

    c)   Void pointer

    d) Null pointer

147. A _____ can be assigned the address of any data type.

    a)  Dangling pointer

    b)  Wild pointer

    c)   Void pointer

    d) Null pointer

148. Which pointer is called general-purpose pointer?

    a)  Dangling pointer

    b)  Wild pointer

    c)   Void pointer    

d) Null pointer

 
 
 

Leave a Comment