You are on page 1of 6

MCQ on C language

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


a)int_a3;
b)inta_3;
c)int3_a;
d)int_3a
View Answer
Answer:
c
Explanation: Variable name cannot start with a digit.

All keywords in C are in ____________


a) LowerCase letters
b) UpperCase letters
c) CamelCase letters
d) None of the mentioned
View Answer
Answer: a
Explanation: None.

Q 5 - What is the built in library function to compare two strings?


A - string_cmp()
B - strcmp()
C - equals()
D - str_compare()

Q 10 - In the given below statement, what does the “arr” indicate?


char *arr[30];
A - arr is a array of function
B - arr is a array of 30 characters
C - arr is a pointer to an array
D - arr is a array of 30 character pointers

The format identifier ‘%i’ is also used for _____ data type?

• A. char

• B. int

• C. float

• D. double

• Answer: Option B
• Explanation:
• Both %d and %i can be used as a format identifier for int data types

Ques.

Is it true that a function may have several declaration, but only one definition.

(A) True
(B) False

Ans. (A)

Hint:
Declaration like int sum(int, int); is allowed number of times but definition int sum(int a, int b) {
return a+b; } is allowed only one time. Multiple definition of same function is compilation error (
redefinition error )

What is the size of an int data type?

• A. 4 Bytes

• B. 8 Bytes

• C. Depends on the system/compiler

• D. Cannot be determined.

• Answer: Option C
• Explanation:
• The size of the data types depend on the system.
Which of the following are themselves a collection of different data types?

• A. String

• B. Structure

• C. Char

• D. All of the mentioned

• Answer: Option B
• Explanation:
• None.

Which of the following cannot be a structure member?

• A. Another structure

• B. Function

• C. Array

• D. None of the mentioned

Answer: Option B

Which of the following structure declaration will throw an error?

• A. struct temp{}s;
main(){}

• B. struct temp{};
struct temp s;
main(){}

• C. struct temp s;
struct temp{};
main(){}

• D. None of the mentioned

Answer: Option D

Which of the following share a similarity in syntax?


1. Union, 2. Structure, 3. Arrays and 4. Pointers

• A. 3 and 4
• B. 1 and 2

• C. 1 and 3

• D. 1, 3 and 4

Answer: Option B

An array Index starts with.?


A) -1
B) 0
C) 1
D) 2
Answer [=]

Option B

Choose a correct statement about C language arrays.


A) An array size can not changed once it is created.
B) Array element value can be changed any number of times
C) To access Nth element of an array students, use students[n-1] as the
starting index is 0.
D) All the above

Ans. D

What is the output of C Program.?


int main()
{
int a[] = {1,2,3,4};
int b[4] = {5,6,7,8};
printf("%d,%d", a[0], b[0]);
}
A) 1,5
B) 2,6
C) 0 0
D) Compiler error
Ans. A
Explanation:
It is perfectly allowed to skip array size if you are initializing at the same
time. a[0] is first element.
int a[] = {1,2,3,4};
An entire array is always passed by ___ to a called function.
A) Call by value
B) Call by reference
C) Address relocation
D) Address restructure
Answer . B

What are the data type of variables that can be returned by a C


Function.?
A) int, float, double, char
B) struct, enum
C) Pointers to variables, arrays, functions, struct variables, enum variables etc
D) All the above

Ans. D

A recursive function can be replaced with __ in c language.


A) for loop
B) while loop
C) do while loop
D) All the above

Ans. D

A recursive function is faster than __ loop.


A) for
B) while
C) do while
D) None of the above

Ans. D

Explanation:
Yes. Recursion is slow. Variable are kept and remove on STACK
memory multiple times.

A recursive function without If and Else conditions will always


lead to.?
A) Finite loop
B) Infinite loop
C) Incorrect result
D) Correct result

Ans. B

Explanation:
Yes. To come out of recursion, you must use IF or ELSE blocks.

You might also like