Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

C Mcqs

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 16

MCQS

UNIT 1

MULTIPLE CHOICE QUESTIONS

1. Which datatype is used to represent the absence of parameters?


a) int
b) short
c) void
d) float

Answer C

2. Which type is best suited to represent the logical values?


a) integer
b) boolean
c) character
d) all of the mentioned

Answer : b
3. Preprocessor Directives are used for –

A] Macro Expansion

B] File Inclusion

C] Conditional Compilation

D] All of these

Answer : D

4. Which of the following is integral data type?


A. Void
B. Char
C. Float
D. Double

Answer : B

5. Which of the following is not derived data type in c?

A. Function
B. Pointer
C. Enumeration
D. Array

Answer : C
6. Which is correct with respect to the size of data types?

A) char > int > float


B).  int > char > float
C) char < int < double
D). double > char > int
Answer : A

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


A. * (asterisk)

B. | (pipeline)

C. - (hyphen)

D. _ (underscore)

Answer: D

8. Which of the following are C preprocessors?


a) #ifdef
b) #define
c) #endif
d) All of the mentioned

Answer: D

9. The syntax to print a % using printf statement can be done by.


a) %
b) %
c) ‘%’
d) %%

Answer: D

10. What does this statement printf(“%10s”, state); means?


a) 10 spaces before the string state is printed
b) Print empty spaces if the string state is less than 10 characters
c) Print the last 10 characters of the string
d) None of the mentioned

Answer: B

FILL IN THE BLANKS


1. ___________ is the range of signed int data type in that compiler in which size of int is
two byte?

Answer: -32767 to 32768

2. __________ is the size of an int data type?

Answer. 4 Bytes
3 . #include <stdio.h> is called _______________
Answer:  Preprocessor directive

4 . A ______________ is a program , That processes its input data to produce output that is
used as input to another program
Answer: Preprocessor

5. If #include is used with file name in angular brackets _______ is searched for in the
standard compiler include paths.

Answer: file

6. ____________ is the purpose of sprintf?

Answer : It writes the formatted data into a string

7. If integer needs two bytes of storage, then maximum value of an unsigned integer is
_______

Answer : 216 – 1
8_______ is the only function all C programs must contain?

Answer: main()

9. _________________ refers to the perminance of a variable and its scope

Answer: storage classes

10. ___________ defines the viaibility if an variable

Answer: scope

UNIT 2

MULTIPLE CHOICE QUESTIONS


1. What is this operator called ?: ?

a) conditional
b) relational
c) casting operator
d) none of the mentioned
Answer : a

2. Which operator has the lowest precedence

A,+
B. –
C. *
D. %

Answer : D

3. When the ____________________ statement is encountered then the rest of statements


in the loop are skipped
A. Break
B. Continue
C. Default
D. Case
Answer : C

4. Which operator has the lowest priority ?

A] ++

B] %

C] +

D] ||

Answer: C

5. The type cast operator is

A] (type)

B] cast()

C] //

D] “ “

Answer: A
6. Which of the following operator takes only integer operands?
A. +

B. *

C /

D. %

Answer: D

Answer:

7. Data type of the controlling statement of a SWITCH statement cannot of the type:
A. int

B. char

C. short

D. float

Answer: D

8. How long the following loop runs?

for(x=0;x=3;x++)
A. four times
B. three times
c. two times
D. never
Answer: D.

9. The CONTINUE statemment cannot be used with


A. goto

B. switch

C. if

D. while

Answer: B
10. The operator & is used for
A] Bitwise AND
B] Bitwise OR
C] Logical AND
D] Logical OR
Answer: A

FILL IN THE BLANKS

1. In C programming language, ____________ operators have the highest precedence

Answer. Arithmetic operators

2. _____________ operator returns the number of bytes occupied by the operand


Answer : sizeof

3. _____________ statements are used to repeat the execution of list of statements

Answer : Iterative

4. Do-while is an ...... loop.


Answer:  Exit control

5. Dangling else problem occurs when ______________


Answer : there is no matching else
6. Explicit type conversion is known as ___________

Answer: Casting

7. The operator + in a+=4 means _______


Answer: a = a + 4

8. The operator && is an example for ___ operator.

Answer: Logical

9. A _____________ statement is used to choose from multiple possibilities which may arise
due to different values of a single variable
Answer: switch

10. __________ is used inside a loop to terminate the current iteration and start with the next
generation [ ]
Answer: break
UNIT 3

MULTIPLE CHOICE QUESTIONS

1. . An array elements are always stored in ________ memory locations.

A. Sequential
B. Random
C. Sequential and Random
D. None of the above
Answer : A

2. 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 };

3. If int warr[3][2][2]={1,2,3,4,5,6,7,8,9,10,11,12}; What will be the value of warr[2][1][0]?

A. 5

B. 7

C. 9

D. 11

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

A. 2

B. 8

C. 50

D. Theoratically no limit. The only practical limits are memory size and compilers.
Answer: D

5. Size of the array need not be specified, when

A. Initialization is a part of definition

B. It is a declaratrion

C. It is a formal parameter

D. All of these

Answer: D

6. Array passed as an argument to a function is interpreted as

A. Address of the array.

B Values of the first elements of the array.

C. Address of the first element of the array.

D. Number of element of the array.

7. Which of the following correctly accesses the seventh element stored in arr, an array
with 100 elements?

A. arr[6]

B. arr[7]

C. arr{6}

D. arr{7}

8. A ______________ is a series of a characters treated as a unit


A. Array
B. Character
C. Record
D. String

9. Among the following which is known as a string literal

A. ‘Hello World’
B. “Hello World”
C. Hello World
D. All of the above

Answer: B

29.

10. int a[5] = {1,2,3} What is the value of a[4]?


A. 3

B. 1

C. 2

D. 0

Answer: D

FILL IN THE BLANKS


1. When array elements are passed to a function with their values, it is called as:-
Answer : Call by value

2.. _________________ is the index of the last element of an array with 9 elements ?

Answer : 8

3. A multidimensional array can be expressed in terms of ----------------


Answer: array of pointers rather than as pointers to a group of
contiguous array
4. Maximum number of elements in the array declaration int a[5][8] is ------------------

Answer: 40

5. If the size of the array is less than the number of initializers then, _________________

Answer: Extra values are being ignored

6. Array subscripts in C always start at ___________ value


Answer: 0

7. The deliemeter in a C string is called as a _____________________

Answer: null character

8. To initialize a string when it is declared, __________ character has to be added at


the end of the string as a delimeter.

Answer: \0

9. ___________ is the return value of the following statement if it is placed in C


program? strcmp("ABC", "ABC");

Answer: 1

10. String concatenation means -

Answer. Combining two strings.

UNIT 4

MULTIPLE CHOICE QUESTIONS

1. The _____________________ string function adds a string at the end of another


string
A. Stradd
B. Strcat
C. Strncat
D. Strtok

Answer: B

2. The _____________________ string function adds a portion of string at the end


of another string
A. Stradd
B. Strcat
C. Strncat
D. Strtok
Answer: C

3. What is the built in library function copies the portion of one string into another
string.

A. Strcpy
B. Strncpy
C. Strncat
D. Strtok

4. Functions are useful in a program because

(A) they increase the execution speed of a program


(B) they make the program organization clearer
(C) a program cannot compile if it does not contain a least one function
(D) the compiler automatically switches to the more powerful function mode when compiling a
program with functions

Answer: B

5. Any c program

A.Must contain at least one function.

B.Need not contain any function.

C.Needs input data.

D.None of the above

6. The default parameter passing mechanism is

A.call by value

B.call by reference

C.call by value result


D.None of these.

Answer: A

7. Which of the following is a complete function?

A.int funct();

B.int funct(int x) { return x=x+1; }

C.void funct(int) { printf(“Hello"); }

D.void funct(x) { printf(“Hello"); }

Answer: B

8. The recursive functions are executed in a ...........

A.Parallel order

B. First In First Out order

C. Last In First Out order

D. Iterative order

Answer: C

9. The function scanf() returns .........

A. The actual values read for each argument.

B. 1

C. 0

D. The number of successful read input values.

Answer:D

10. Which of the following function calculates the square of 'x' in C?


A. sqr(x)

B. pow(2, x)

C.. pow(x, 2)

D. power(2, x)

Answer:C

FILL IN THE BLANKS

1. A function which is called is refered as :-


 Answer   called function

 2. In which type, the values are passed to a function?


 Answer   call by value

3.. A function that calls itself for its processing is known as ______________

Answer :  Recursive Function

4. We declare a function with ______ if it does not have any return type

Answer : void

5. Variables inside parenthesis of functions declarations have _____ level access.

Answer. Local

6. When a function is recursively called all the automatic variables are stored in
a ..........

Answer: Stack

7.. ________ type of inputs are accepted by mathematical functions?

Answer: double

8.The _____________________ string function adds a string at the end of another string

Answer: Strcat
9. In __________ order actual arguments are evaluated in function call 10 . Arguments
of a functions
Answer:  is compiler dependent
are separated
with ------------

Answer: . comma (,)

UNIT 5

MULTIPLE CHOICE QUESTIONS

MULTIPLE CH

1. Pointer is a Special kind of variable is used to store ____________ of the variable.


A. Address
B. Data Type
C. Value
D. Variable Name
A

2. pointer that is pointing to NOTHING is called ____ 

A.VOID Pointer
B. DANGLING Pointer

C. NULL Pointer
D. WILD Pointer
Answer C

3. An uninitialized pointer in C is called ___ 

A. Constructor
B. dangling pointer
C. Wild Pointer
D. Destructor

C
4. Which of the following are themselves a collection of different data types?
a) string
b) structures
c) char
d) All of the mentioned
Answer: b

5.User-defined data type can be derived by___________.


a) struct
b) enum
c) typedef
d) All of the mentioned
Answer: d

6. Which operator connects the structure name to its member name?

a) –
b) <-
c) .
d) Both (b) and (c)
Answer: C

7. typedef declaration
a) Does not create a new type
b) It merely adds a new name for some existing type.
c) Both a & b
d) None of the mentioned
Answer: c

8.. Size of a union is determined by size of the.

a) First member in the union


b) Last member in the union
c) Biggest member in the union
d) Sum of the sizes of all members

Answer: C

9. The size of structure and union is same when they contain


a)single member
b) any number of members
c) a & b
d) none
Answer: C

10. The operator used to find the size of any variable


a) sizeof
b) Sizeof
c) sizeOf
d) all the above
Answer: A

FILL IN THE BLANKS

1. "&" is called as ___________ in pointer concept.


Answer: Address Operator

2. Pointer variable is declared using preceding _________ sign.


Answer: *

3. Address stored in the pointer variable is of type __________.


Answer: Integer

4. In order to fetch the address of the variable we write preceding _________ sign
before variable name.

Answer: Ampersand

5. What is the another name of 'value at address' operator?


  Answer   indirection

  6. .The operator used to access the member of structure is

Answer: 

7. Union can store _________ number of values at a time

Answer : all its members

8. Members of a union are accessed as________________. & ____________


Answers:
union-name.member
union-pointer->member

9. ___________ is the correct syntax to access the member of the ith structure in the array of
structures is?
    Assuming: struct temp
    {
        int b;
    }s[50];

Answer: s[i].b;

10. ___________ is the correct syntax to declare a function foo() which receives an array of
structure in     function?

Answer: void foo(struct *var);

You might also like