Home

C Programming 1000+ MCQ with answer for LIC AAO

Thursday 9th of March 2023

Sharing is caring

1. The contents of a file opened in 'r+' mode cannot be changed.
A. True
B. False
C.
D.
Answer : B
2. If the class name is X, what is the type of its “this” pointer (in a nonstatic, non-const member function)?
A. const X* const
B. X* const
C. X*
D. X&
Answer : D
3. What is right way to Initialization 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 } ;
Answer : A
4. The value of an enumerated datatype can be read using scanf() function.
A. True
B. False
C.
D.
Answer : B
5. All macro substitutions in a program are done before compilation of the program.
A. True
B. False
C.
D.
Answer : A
6. fopen() function returns a pointer to the open file.
A. True
B. False
C.
D.
Answer : A
7. The printf() function retunes which value when an error occurs?
A. Positive value
B. Zero
C. Negative value
D. None of these
Answer : C
8. Each pass through a loop is called a/an
A. enumeration
B. iteration
C. culmination
D. pass through
Answer : C
9. All elements of a structure are allocated contiguous memory locations.
A. True
B. False
C.
D.
Answer : A
10. An array elements are always stored in _________ memory locations.
A. Sequential
B. Random
C. Sequential and Random
D. None of the above
Answer : A
11. Which one of the following is not a fundamental data type in C++
A. float
B. string
C. int
D. wchar_t
Answer : A
12. ------ is the ternary operator
A. ?,-
B. ?,:
C. ++<--
D. none of the above
Answer : B
13. A pointer is an indication of the variable to be accessed next.
A. True
B. False
C.
D.
Answer : B
14. gets() and puts() are unformatted I/O functions.
A. True
B. False
C.
D.
Answer : A
15. The output of the following code is:
int f(int a, int b); 
void main()
{
int a = 12, b=154;
printf("%d", f(a, b));
}
int f(int a, int b)
{
if (a<b) return(f(b, a));
if(b==0) return(a);
return (f(b, a % b));
}

A. 2
B. 1
C. Compilation error
D. Runtime error
Answer : A
16. fprintf()function can be used to write into console.
A. True
B. False
C.
D.
Answer : B
17. Identify the wrong statement
A. putchar(65)
B. putchar('x')
C. putchar("x")
D. putchar('
')
Answer : C
18. Nested macros are allowed.
A. True
B. False
C.
D.
Answer : B
19. Which of the following is the most preferred way of throwing and handling exceptions?
A. Throw by value and catch by reference.
B. Throw by reference and catch by reference.
C. Throw by value and catch by value
D. Throw the pointer value and provide catch for teh pointer type.
Answer : B
20. Which among the following is a unconditional control structure
A. do-while
B. if-else
C. goto
D. for
Answer : C
21. The output of the following code is:
main() 
{
int a = 5, b = 6;
(a == b? printf("%d", a));
}

A. 0
B. 5
C. Error
D. None of the above
Answer : C
22. A function to be called must be ended with a----------------
A. .
B. ?
C. ;
D. none of the above
Answer : C
23. C is a ___ language
A. High Level and Procedural
B. Low Level and OOPS
C. Middle Level and Procedural
D. Machine Level and OOPS
Answer : A
24. What is Keywords?
A. Keywords have some predefine meanings and these meanings can be changed.
B. Keywords have some unknown meanings and these meanings cannot be changed.
C. Keywords have some predefine meanings and these meanings cannot be changed.
D. None of the above
Answer : C
25. Which of the following expressions is wrong
A. float a =123.56;
B. char ch ='T' * 'A';
C. char ch ='T' *20;
D. 3 +a = b;
Answer : D
26. The-------------------- statement helps immediate exit from any part of the loop
A. break
B. continue
C. exit
D. All of the above
Answer : A
27. For 16?bit compiler allowable range for integer constants is ______ ?
A. ?3.4e38 to 3.4e38
B. ?32767 to 32768
C. ?32768 to 32767
D. ?32668 to 32667
Answer : C
28. The -------------------------- loop executes at least once.
A. for
B. while
C. do-while
D. while & do-while
Answer : C
29. Which of the following is not recommended in a header file?
A. Type definitions (typedefs)
B. Class definitions
C. Function definitions
D. Template definitions
Answer : D
30. Every if statement can be converted into an equivalent switch statement.
A. True
B. False
C.
D.
Answer : B
31. Which of the following is not an infinite loop
A. int i =1;
while (1)
{i++;}
B. for( ; ; );
C. int true=0< false;
while (true)
{false = 1;}
D. int y, x = 0;
do
{y = x;}
while (x==0);
Answer : C
32. The output of the following code is:
void main()
{
int a = 20;
printf("%d\t%d
", ++a, a);
}

A. 21 21
B. 20 21
C. 21 20
D. 20 20
Answer : C
33. What is the right way to access value of structure variable book{ price, page }?
A. printf("%d%d", book.price, book.page);
B. printf("%d%d", price.book, page.book);
C. printf("%d%d"< price::book< page::book);
D. printf("%d%d", price?>book, page?>book);
Answer : A
34. If 'str' is a string of 7 characters, the statement printf("%4s", str); will display ------characters.
A. 4
B. 7
C. 6
D. 0
Answer : A
35.

What will be output if you will compile and execute the following c code?


#include 
#define x 5+2
int main(){
int i;
i=x*x*x;
printf("%d",i);
return 0;
}



A. 27
B. 343
C. 233
D. Compiler Error
Answer : A
36. Which of the following shows the correct hierarchy of arithmetic operations in C
A. / + * ?
B. * ? / +
C. + ? / *
D. * / + -
Answer : D
37. void' is a datatype.
A. True
B. False
C.
D.
Answer : A
38. Which header file is essential for using strcmp() function?
A. string.h
B. strings.h
C. text.h
D. strcmp.h
Answer : A
39. No commas or blanks are allowed within an integer or a real constant.
A. True
B. False
C.
D.
Answer : A
40. Which of the STL containers store the elements contiguously (in adjecent memory locations)?
A. std::vector
B. std::list
C. std::map
D. std::set
Answer : C
41. = and = = have the same operation.
A. True
B. False
C.
D.
Answer : B
42. Which of the following keyword supports dynamic method resolution?
A. abstract
B. Virtual
C. Dynamic
D. Typeid
Answer : A
43. The output of the following code is:
void main() 
{
int a = 0;
while (a<=50) for(;;) if(++a % 50==0) break;
printf("a = %d", a);
}

A. a = 100
B. a = 50
C. compilation error
D. runtime error
Answer : A
44. Which of the following is a valid destructor of the class name "Country"
A. int ~Country()
B. void Country()
C. int ~Country(Country obj)
D. void ~Country()
Answer : B
45. What is an array?
A. An array is a collection of variables that are of the dissimilar data type.
B. An array is a collection of variables that are of the same data type.
C. An array is not a collection of variables that are of the same data type.
D. None of the above.
Answer : B
46. Which of the following is an example of compounded assignment statement?
A. a = 5
B. a += 5
C. a = b = c
D. a = b
Answer : C
47. The output of the following code is:
#define sqr(x= x*x) 
main()
{
int a = 10, b = 5;
printf("%d, %d", sqr(a+b),sqr(++a));
}

A. 77, 121
B. 225, 121
C. 77< 144
D. Compilation error
Answer : D
48. The output of the following code is:
void main() 
{
int a = 1, b=2;
int *ip;
ip=&a;
b=*ip;
printf("%d", b);
}

A. 2
B. 1
C. 100
D. 0
Answer : B
49. What will be output if you will compile and execute the following c code?
#include 
int main()
{
float a=5.2;
if(a==5.2)
printf("Equal");
else if(a<5.2)
printf("Less than");
else
printf("Greater than");
return 0;
}

A. Less than
B. Equal
C.

Greater than


D. None of above
Answer : A
50. The array 'char name[10] can consist of a maximum of 9 characters.
A. True
B. False
C.
D.
Answer : A

Sharing is caring