C language MCQ Part-21) Array is a _________ data structure.
Answer: (c) Linear Explanation: An array is a non-primitive and linear data structure that only stores a similar data type. 2) Which of the following statement is correct about the array?
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. 3) Which of the following statement is correct about the C language?
Answer: (c) The C language is a mid-level language with some high features. Explanation: C is considered a middle-level language because it supports the feature of both low-level and high-level languages. Today, many programmers refer to C as a low-level language because it lacks a large runtime system (no garbage collection, etc.). It supports only scalar operations and provides direct memory addressing. 4) In the following program fragment, s and b are two integers: What does it intend to do?
Answer: (a) Exchange the values of s and b 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: 5) Study the following program fragment What will be the output of this program fragment?
Answer: (c) rings the bell 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". 6) Study the following statement What will be the output of this statement?
Answer: (d) None of the these Explanation: On execution, 9/5 will produce integer 1. If we print 1 as a floating number, only garbage will be printed. 7) A global variable is declared __________.
Answer: (a) Outside of the function Explanation: A global variable is a variable that is declared outside of the function. A global variable can be used in all functions. 8) Who defines the user-defined function?
Answer: (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. 9) Which of the following functions is already declared in the "header file"?
Answer: (b) Built-in function 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. 10) Which of the following operations cannot be performed in file handling?
Answer: (d) None of the these 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:
Therefore, option (d) is the correct answer. 11) Which of the following function is used to write the integer in a file?
Answer: (b) putw() Explanation: The putw() is used to write the integer in a file. Syntax: putw(int i, FILE *fp); 12) Which of the following statement is correct about the ftell() function?
Answer: (a) It returns the current position. Explanation: The ftell() function returns the current position of the file pointer in a stream. Syntax of ftell() function: 13) Study the following program: What will be the output of this program?
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?
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?
Answer: (c) Integer 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?
Answer: (b) const 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. 17) Which of the following declarations is invalid in C language?
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.
Answer: (a) Integer Explanation: Enumeration is a user-defined data type in C language that is used to assign names to integral constants. It is represented by the "enum" keyword. 19) Study the following program: What will be the output of this program?
Answer: (b) error: redeclaration of an enumerator 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)?
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. 21) Which of the following is not an arithmetic operation?
Answer: (d) x ! = 56; Explanation: There are five arithmetic operators in the C language. 22) Which of the following operator is represented a relational operation?
Answer: (a) == Explanation: The relational expression is used to compare two operands. It is a condition expression. The following operators are relational operators.
23) Which of the following keyword is used for union in c language?
Answer: (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. 24) Study the following program fragment What will store in ch?
Answer: (b) 90 Explanation: The capital 'Z' value is 90 accordingly to the ASCII table. Therefore, 90 will be assigned to ch variable. 25) Study the following program: What will be the output of this program?
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. 26) Which of the following variable name is correct in c language?
Answer: (a) For 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. 27) Which of the following header files is not used in C language?
Answer: (c) <iostream.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?
Answer: (b) <ctype.h> Explanation: The <ctype.h> header file is used for character type function in C language. 29) Which of the following declaration is incorrect in C language?
Answer: (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?
Answer: (a) 28087 Explanation: a = 0x6db7, that means, 0x6db7 is a hexadecimal code. =0x6db7 << 6 = 0110 1101 1011 0111 << 6 = 0110 1101 1100 0000 = 28087 (in decimal) 31) If a = 0x6db7 and b = 0xa726, what will be the value of a&b?
Answer: (b) 9510 Explanation: a = 0x6db7 b = 0xa726 Both a and b values are hexadecimal value. = 0x6db7 & 0xa726 = 0110 1101 1011 0111 & 1010 0111 0010 0110 = 0010 0101 0010 0110 = 0x2526 = 9510 (in decimal) 32) If a = 0x6db7 and b = 0xa726, what will be the value of a^b?
Answer: (c) 51587 Explanation: a = 0x6db7 b = 0xa726 Both a and b values are hexadecimal value. = 0110 1101 1011 0111 ^ 1010 0111 0010 0110 = 1100 1010 1001 0001 = 0xca91 = 51857 (in decimal) 33) Study the following program: What will be the output of this program?
Answer: (c) 5 Explanation: x = 4 % -5 + 6 % 5 x = 4 + 6 % 5 x = 4 + 1 x = 5 34) Study the following program: What will be the output of this program?
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. 35) Which one of the following operators is a unary operator in c language?
Answer: (d) sizeof() Explanation: The sizeof () operator is a compile-time unary operator that is used to compute the size of the operand. 36) Study the following program: What will be the output of this program?
Answer: (b) 105 Explanation: None 37) How many types of variables are there in the C language?
Answer: (a) 2 Explanation: There are two types of variables:
38) Which of the following is the variable that can be used for all functions?
Answer: (b) Global variable Explanation: The global variable is a variable, which is declared outside of the functions. A global variable can be used in all functions. 39) Which symbol is used to declare a pointer?
Answer: (a) * Explanation: To declare a pointer variable, we use a '*' symbol before the pointer variable. 40) Which of the following initialization is incorrect in C language?
Answer: (d) None of the these Explanation: All these declarations are correct in the C language. Therefore, option (d) is the correct answer. Next Topic# |