C language MCQ1) What is the 16-bit compiler allowable range for integer constants?
Answer: (d) -32768 to 32767 Explanation: In a 16-bit C compiler, we have 2 bytes to store the value.
2) Study the following program: What will be the output of this program?
Answer: (b) It will keep on printing javatpoint Explanation: In this program, the main function will call itself again and again. Therefore, it will continue to print javatpoint. 3) What is required in each C program?
Answer: (a) The program must have at least one function. Explanation: Any C program has at least one function, and even the most trivial programs can specify additional functions. A function is a piece of code. In other words, it works like a sub-program. 4) What will this program print?
Answer: (a) 4525 Explanation: In this program, it will first print the inner value of the function and then print the outer value of the function. 5) Which of the following comment is correct when a macro definition includes arguments?
Answer: (a) The opening parenthesis should immediately follow the macro name. Explanation: None 6) What is a lint?
Answer: (c) Analyzing tool Explanation: Lint is an analyzing tool that analyzes the source code by suspicious constructions, stylistic errors, bugs, and flag programming errors. Lint is a compiler-like tool in which it parses the source files of C programming. It checks the syntactic accuracy of these files. 7) What is the output of this statement "printf("%d", (a++))"?
Answer: (b) The current value of "a". Explanation: None 8) Study the following program: If abcdefg is the input, the output will be
Answer: (c) efg Explanation: None 9) Study the following program: What will be the output of this program?
Answer: (d) 8 Explanation: It is an effect of the comma operator. a + = (a + = 3, 5, a) It first evaluates to "a + = 3" i.e. a = a + 3 then evaluate 5 and then evaluate "a". Therefore, we will get the output is 4. Then, a + = 4 It gives 8 as the output. 10) What does this declaration mean?
Answer: (c) X is a four-bit integer. Explanation: This means, "X" is a four bit integer. 11) Why is a macro used in place of a function?
Answer: (d) It reduces code size. Explanation: Macro is used in place of a function because it reduces code size, and very efficient. 12) In the C language, the constant is defined _______.
Answer: (c) Anywhere, but starting on a new line. Explanation: In the C language, the constant is defined anywhere, but starting on a new line. 13) How many times will the following loop execute?
Answer: (a) Forever Explanation: None 14) A pointer is a memory address. Suppose the pointer variable has p address 1000, and that p is declared to have type int*, and an int is 4 bytes long. What address is represented by expression p + 2?
Answer: (d) 1008 Explanation: None 15) What is the result after execution of the following code if a is 10, b is 5, and c is 10?
Answer: (b) a = 11, c = 10 Explanation: None 16) Which one of the following is a loop construct that will always be executed once?
Answer: (d) do while Explanation: The body of a loop is often executed at least once during the do-while loop. Once the body is performed, the condition is tested. If the condition is valid, it will execute the body of a loop; otherwise, control is transferred out of the loop. 17) Which of the following best describes the ordering of destructor calls for stack-resident objects in a routine?
Answer: (b) The first object destroyed is the last object destroyed; last created is first destroyed. Explanation: None 18) How many characters can a string hold when declared as follows?
Answer: (b) 20 Explanation: None 19) Directives are translated by the
Answer: (a) Pre-processor Explanation: In C language, the pre-processor is a macro processor that is dynamically used by the C programmer to modify the program before it is properly compiled (Before construction, pro-processor directives are implemented). 20) How many bytes does "int = D" use?
Answer: (c) 2 or 4 Explanation: The int type takes 2 or 4 bytes. 21) What feature makes C++ so powerful?
Answer: (d) All of the above Explanation: None 22) Which of the following will copy the null-terminated string that is in array src into array dest?
Answer: (c) strcpy(dest, src) Explanation: strcpy is a string function that is used to copy the string between the two files. strcpy(destination, source) 23) In the statement "COUT << "javatpoint" << end1;", end1 is a ___.
Answer: (c) Manipulator Explanation: End1 is an I/O manipulator that takes effect in printing a new line '\ n' character and then flushing the output stream. 24) Each instance of a class has a different set of
Answer: (d) Attribute values Explanation: Each instance of the class has a different set of attribute values 25) How many instances of a class can be declared?
Answer: (c) As per required Explanation: You can always declare multiple instances of a class, as per required. Each object will hold its own individual inner variables (unless they are static, in which case they are shared). 26) What will the result of num variable after execution of the following statements?
Answer: (a) 3 Explanation: num = 58 num % = 11 num = num % 11 num = 58 % 11 num = 3 27) What is the maximum number of characters that can be held in the string variable char address line [40]?
Answer: (b) 39 Explanation: None 28) What will the result of num1 variable after execution of the following statements?
Answer: (c) 13 Explanation: None 29) What will the result of len variable after execution of the following statements?
Answer: (c) 13 Explanation: strlen is a string function that counts the word and also count the space in the string. (39 march road) = 13 30) Study the following statement What will be the output?
Answer: (d) 11, 11 Explanation: None 31) Given the following statement, what will be displayed on the screen?
Answer: (b) 102 Explanation: aPtr is an integer pointer which value is 100. = *aPtr + 2 = 100 + 2 = 102 32) Give the following declarations and an assignment statement. Which one is equivalent to the expression str [4]?
Answer: (c) *(p + 4) Explanation: None 33) Which one is the correct description for the variable balance declared below?
Answer: (b) Balance is a pointer to a pointer to an integer Explanation: This code description states that the remainder is a pointer to a pointer to an integer. 34) A class D is derived from a class B, b is an object of class B, d is an object of class D, and pb is a pointer to class B object. Which of the following assignment statement is not valid?
Answer: (c) d = b; Explanation: A class D is derived from a class B, so "d" is not equal to b. 35) Which of the following statement is not true?
Answer: (b) A pointer must point to a data item on the heap (free store). Explanation: None 36) Which of the following SLT template class is a container adaptor class?
Answer: (a) Stack Explanation: Container Adaptors is the subset of Containers that provides many types interface for sequential containers, such as stack and queue. 37) What kinds of iterators can be used with vectors?
Answer: (d) All of the above Explanation: An iteration is like a pointer, indicating an element inside the container. All these types of iterations can be used with vectors. 38) Let p1 be an integer pointer with a current value of 2000. What is the content of p1 after the expression p1++ has been evaluated?
Answer: (c) 2004 Explanation: The size of one pointer integer is 4 bytes. The current value of p1 is 2000. p1++ = p1 + 1 p1++ = 2004 39) Let p1 and p2 be integer pointers. Which one is a syntactically wrong statement?
Answer: (a) p1 = p1 + p2; Explanation: None 40) Suppose that cPtr is a character pointer, and its current content is 300. What will be the new value in cPtr after the following assignment?
Answer: (a) 305 Explanation: cPtr = cPtr + 5 cPtr = 300 + 5 cPtr = 305 41) Which is valid expression in c language?
Answer: (b) int my_num = 100000; Explanation: Special symbol, Space, and comma cannot be used in a variable name in c language. 42) If addition had higher precedence than multiplication, then the value of the expression (1 + 2 * 3 + 4 * 5) would be which of the following?
Answer: (d) 105 Explanation: (1 + 2 * 3 + 4 * 5) = (1 + 2) * (3 + 4) * 5 = 3 * 7 * 5 = 105 43) What will be the output of this program?
Answer: (c) a = 20, b = 10 Explanation: This program is a swapping program. a = a + b → a = 10 + 20 → a = 30 b = a - b → b = 30 - 20 → B = 10 a = a - b → a = 30 - 10 → a = 20 44) The following statements are about EOF. Which of them is true?
Answer: (e) All of the these Explanation: All statements are true 45) What does this statement mean?
Answer: (d) x = x - y - 1 Explanation: x - = y + 1 x = x - (y + 1) So, x = x - y - 1 46) Study the following statement What will be the output?
Answer: (c) 3 7 15 Explanation: None 47) Study the following statement What will be the output?
Answer: (b) Hello, World! Explanation: The output of this program is "Hello, World!". This program's output will not appear in the new line because the \ n escape sequence has not been used in this program. 48) Study the following array definition Which of the following statement is correct?
Answer: (a) num[9] is the last element of the array num Explanation: The num[9] is the last element of the array number because the total element in this array is 10, and the array starts with 0, so the last element of the array is the num[9]. 49) What will the output after execution of the following statements?
Answer: (d) hai Explanation:
50) What will the output after execution of the following statements?
Answer: (b) 53 65 Explanation: This value (065) is an octal value, and it equals to the decimal value 53. Next TopicC MCQ Part 2 |