C Language MCQ Part 2 (Multiple Choice Questions) - Javatpoint
C Language MCQ Part 2 (Multiple Choice Questions) - Javatpoint
C Language MCQ Part 2 (Multiple Choice Questions) - Javatpoint
Home C C++ C# Java SQL HTML CSS JavaScript XML Ajax Android
https://www.javatpoint.com/c-language-mcq-part-2 1/26
2/12/24, 9:18 PM C language MCQ Part 2 (Multiple Choice Questions) - javatpoint
ADVERTISEMENT
a. Non-linear
b. Primary
c. Linear
d. Data type
Explanation: An array is a non-primitive and linear data structure that only stores a similar data
type.
a. In the array, users can only allocate the memory at the run time.
b. In the array, users can only allocate the memory at the compile time.
c. The array is a primitive and non-linear data structure that only stores a similar data type.
Answer: (b) In the array, users can only allocate the memory at the compile time.
Explanation: An array is a non-primitive and linear data structure that only stores a similar data
type. In array, users can only allocate the memory at the compile time.
https://www.javatpoint.com/c-language-mcq-part-2 2/26
2/12/24, 9:18 PM C language MCQ Part 2 (Multiple Choice Questions) - javatpoint
Answer: (c) The C language is a mid-level language with some high features.
b=s+b
s=b-s
b=b-s
Explanation: The intention of this program fragment is to exchange (swap) the values of s and b.
Let us take an example for better understand:
s=1
b=2
b=s+b
b=1+2
b=3
s=b-s
s=3-1
s=2
b=b-s
b=3-2
b=1
int i = 263;
putchar(i);
a. prints 263
d. prints garbage
https://www.javatpoint.com/c-language-mcq-part-2 4/26
2/12/24, 9:18 PM C language MCQ Part 2 (Multiple Choice Questions) - javatpoint
Explanation: 263 is equivalent to binary number 100000111. If the user tries to print an integer
as a character, only the last 8 bits are considered, and the remaining ones are ignored. In this
program, the ASCII value of 100000111 will be 00000111 (i.e., decimal 7). Therefore, this program
will print "ringing the bell".
a. 1.8
b. 1.0
c. 2.0
Explanation: On execution, 9/5 will produce integer 1. If we print 1 as a floating number, only
garbage will be printed.
https://www.javatpoint.com/c-language-mcq-part-2 5/26
2/12/24, 9:18 PM C language MCQ Part 2 (Multiple Choice Questions) - javatpoint
Explanation: A global variable is a variable that is declared outside of the function. A global
variable can be used in all functions.
a. Compiler
b. Computer
c. Compiler library
d. Users
Explanation: The user-defined functions are those functions that are defined by the user while
writing the program. The user can define these functions according to their needs.
a. User-define function
b. Built-in function
c. C function
https://www.javatpoint.com/c-language-mcq-part-2 6/26
2/12/24, 9:18 PM C language MCQ Part 2 (Multiple Choice Questions) - javatpoint
Explanation: Built-in functions are those functions whose prototypes are preserved in the
header file of the "C" programming language. These functions are called and executed only by
typing their name in the program. For example, scanf(), printf(), strcat(), etc.
c. To write a file
Explanation: File handling is a process in which data is stored in a file using a program. The
following operations can be performed in file handling:
Open file
Delete file
File closing
11) Which of the following function is used to write the integer in a file?
a. getw()
b. putw()
c. int value
d. f_int()
Syntax:
12) Which of the following statement is correct about the ftell() function?
Explanation: The ftell() function returns the current position of the file pointer in a stream.
#include <stdio.h>
int main() {
int i = 5;
printf("%d", i = ++i == 6);
return 0;
}
https://www.javatpoint.com/c-language-mcq-part-2 8/26
2/12/24, 9:18 PM C language MCQ Part 2 (Multiple Choice Questions) - javatpoint
a. 2
b. 6
c. 4
d. 1
Answer: (a) 1
Explanation: The expression can be treated as i = (++i == 6), because "==" is of higher
precedence than "=" operator. In the inner expression, ++i is equal to 6. Hence, the result is 1.
14) In which of the following modes, the user can read and write the file?
a. r
b. w
c. r+
d. b+
Answer: (c) r+
Explanation: r+ mode opens the text file in both reads and writes modes.
15) What type of data type does the atoi() function return?
a. String
b. char
c. Integer
https://www.javatpoint.com/c-language-mcq-part-2 9/26
2/12/24, 9:18 PM C language MCQ Part 2 (Multiple Choice Questions) - javatpoint
d. Float
Explanation: The atoi() takes the string data type and returns the integer data type. This means
it converts the string argument into an integer.
16) Which of the following keywords is used to prevent any kind of change in a variable?
a. continue
b. const
c. struct
d. extern
Explanation: Constant is a variable whose value cannot be changed once assigned. Constant is
also called literals. It can be of any basic data type such as char, integer, float, and string. It can
be defined anywhere in the program but in a new line. It is represented by the const keyword.
Answer: (d) char[] str = "javatpoint is the best platform for learn";
Explanation: This declaration is valid in java language, but not in C language. Therefore, option
(d) is the correct answer.
18) The enum keyword is used to assign names to the ________ constants.
a. Integer
b. String
c. Character
ADVERTISEMENT ADVERTISEMENT
#include<stdio.h>
enum flg{a, b, c};
https://www.javatpoint.com/c-language-mcq-part-2 11/26
2/12/24, 9:18 PM C language MCQ Part 2 (Multiple Choice Questions) - javatpoint
a. 1
c. h
d. 3
Explanation: There is a declaration error in the output of this program because the declaration
of the enum function is the same.
20) Which of the following operator's precedence order is correct (from highest to lowest)?
a. %, *, /, +, -
b. %, +, /, *, -
c. +, -, %, *, /
d. %, +, -, *, /
Answer: (a) %, *, /, +, -
Explanation: The precedence of operator species that which operator will be evaluated first and
next. When two operators share an operand, the operator with the higher precedence goes first.
https://www.javatpoint.com/c-language-mcq-part-2 12/26
2/12/24, 9:18 PM C language MCQ Part 2 (Multiple Choice Questions) - javatpoint
a. x * = 65;
b. x / = 42;
c. x % = 2;
d. x ! = 56;
a. ==
b. ++
c. ||
d. &&
% Modulo division
* Multiplication
/ Division
+ Addition
- Subtraction
== Equal to
!= Not equal to
https://www.javatpoint.com/c-language-mcq-part-2 13/26
2/12/24, 9:18 PM C language MCQ Part 2 (Multiple Choice Questions) - javatpoint
a. un
b. unt
c. ion
d. union
Explanation: Union is a special data type by which we store different data types in the same
memory location. The union keyword is used to define a union data type.
char ch = 'Z'
a. Z
b. 90
c. 91
d. 122
Answer: (b) 90
https://www.javatpoint.com/c-language-mcq-part-2 14/26
2/12/24, 9:18 PM C language MCQ Part 2 (Multiple Choice Questions) - javatpoint
Explanation: The capital 'Z' value is 90 accordingly to the ASCII table. Therefore, 90 will be
assigned to ch variable.
main ()
{
if(5 < '5')
printf("5")
else
printf("Not equal to 5.")
}
a. ENQ
b. 5
c. I
d. Not equal to 5
Answer: (b) 5
Explanation: This program will print 5 because '5' is a decimal value, and it is equal to 53 in the
ASCII table. Therefore, the condition is true and returns 5.
a. For
b. for
c. Basic salary
d. hello.
https://www.javatpoint.com/c-language-mcq-part-2 15/26
2/12/24, 9:18 PM C language MCQ Part 2 (Multiple Choice Questions) - javatpoint
Explanation: The "for" is an incorrect variable name because it is a keyword in the C language.
The "Basic salary" is the incorrect variable name because space is not allowed within the variable
name. Hello. is incorrect because '.' is not allowed within the variable name. Therefore, option (a)
is the correct answer.
a. <assert.h>
b. <ctype.h>
c. <iostream.h>
d. <locale.h>
Explanation: <iostream.h> header file is used for basic input and output services in C++
language.
28) Which of the following header files is used for character type function in C language?
a. <assert.h>
b. <ctype.h>
c. <iostream.h>
d. <locale.h>
Explanation: The <ctype.h> header file is used for character type function in C language.
https://www.javatpoint.com/c-language-mcq-part-2 16/26
2/12/24, 9:18 PM C language MCQ Part 2 (Multiple Choice Questions) - javatpoint
a. scanf("%d%d", a, b);
b. scanf("%d%d", a b);
Explanation: Option (b) is an incorrect declaration in the C language because the variable name
is not separated by a comma.
30) If a = 0x6db7, what will be the value of "a << 6" in decimal?
a. 28087
b. 28996
c. 29512
d. 29096
https://www.javatpoint.com/c-language-mcq-part-2 17/26
2/12/24, 9:18 PM C language MCQ Part 2 (Multiple Choice Questions) - javatpoint
a. 9814
b. 9510
c. 9045
d. 9305
Explanation: a = 0x6db7
b = 0xa726
= 0x2526
a. 51956
b. 51256
c. 51857
d. 51235
Explanation: a = 0x6db7
https://www.javatpoint.com/c-language-mcq-part-2 18/26
2/12/24, 9:18 PM C language MCQ Part 2 (Multiple Choice Questions) - javatpoint
b = 0xa726
= 0xca91
main ()
{
int x;
x = 4 % -5 + 6 % 5;
printf("\nx = %d", x);
}
a. 10
b. 9
c. 5
d. 3
Answer: (c) 5
Explanation: x = 4 % -5 + 6 % 5
x=4+6%5
x=4+1
x=5
https://www.javatpoint.com/c-language-mcq-part-2 19/26
2/12/24, 9:18 PM C language MCQ Part 2 (Multiple Choice Questions) - javatpoint
ADVERTISEMENT ADVERTISEMENT
main ()
{
char x;
x = 'A' + 5;
printf("%c", x);
}
a. A + 5
b. A
c. 5
d. F
Answer: (d) F
Explanation: This program will print F because capital 'A' is equal to 65 according to the ASCII
table. Therefore, 'A + 5' is equal to 70, and the value of 70 is F.
a. &
b. &&
https://www.javatpoint.com/c-language-mcq-part-2 20/26
2/12/24, 9:18 PM C language MCQ Part 2 (Multiple Choice Questions) - javatpoint
c. <<
d. sizeof()
Explanation: The sizeof () operator is a compile-time unary operator that is used to compute the
size of the operand.
#include <stdio.h>
#define a( i, j ) printf("%d", j##i )
int main()
{
a(5, 10);
}
a. 510
b. 105
c. Compiler error
d. Declaration error
Explanation: None
a. 2
b. 4
c. 1
https://www.javatpoint.com/c-language-mcq-part-2 21/26
2/12/24, 9:18 PM C language MCQ Part 2 (Multiple Choice Questions) - javatpoint
d. 5
Answer: (a) 2
Global variable
Local variable
38) Which of the following is the variable that can be used for all functions?
a. Static variable
b. Global variable
c. Local variable
d. Dynamic variable
Explanation: The global variable is a variable, which is declared outside of the functions. A
global variable can be used in all functions.
a. *
b. #
c. &
d. &&
Answer: (a) *
Explanation: To declare a pointer variable, we use a '*' symbol before the pointer variable.
https://www.javatpoint.com/c-language-mcq-part-2 22/26
2/12/24, 9:18 PM C language MCQ Part 2 (Multiple Choice Questions) - javatpoint
int *k;
Explanation: All these declarations are correct in the C language. Therefore, option (d) is the
correct answer.
← Prev Next →
https://www.javatpoint.com/c-language-mcq-part-2 23/26
2/12/24, 9:18 PM C language MCQ Part 2 (Multiple Choice Questions) - javatpoint
Feedback
Preparation
https://www.javatpoint.com/c-language-mcq-part-2 24/26
2/12/24, 9:18 PM C language MCQ Part 2 (Multiple Choice Questions) - javatpoint
Company
Interview
Questions
Company Questions
Trending Technologies
B.Tech / MCA
https://www.javatpoint.com/c-language-mcq-part-2 25/26
2/12/24, 9:18 PM C language MCQ Part 2 (Multiple Choice Questions) - javatpoint
Software
Engineering
https://www.javatpoint.com/c-language-mcq-part-2 26/26