Home

C Programming 1000+ MCQ with answer for CAT

Thursday 9th of March 2023

Sharing is caring

1. The expression (i + j)++ is illegal.
A. True
B. False
C.
D.
Answer : A
2. A pointer is an indication of the variable to be accessed next.
A. True
B. False
C.
D.
Answer : B
3. The output of the following code is:
void main()
{
int z, a = 5, b = 3; z = a * 2 + 26 % 3;
printf("%d", z); }

A. 10
B. 0
C. 12
D. None of the above
Answer : C
4. What's wrong? (x = 4 && y = 5) ? (a = 5) ; (b = 6);
A. the question mark should be an equal sign
B. the first semicolon should be a colon
C. there are too many variables in the statement
D. the conditional operator is only used with apstrings
Answer : D
5. Which of the following shows the correct hierarchy of arithmetic operations in C
A. / + * ?
B. * ? / +
C. + ? / *
D. * / + -
Answer : D
6. the value *(&i) is same as printing the value of address of i.
A. True
B. False
C.
D.
Answer : B
7. The output of the following code is:
void change (char *k) 
{
k="Hello";
return;
}
main()
{
char *ch = "World";;
change(ch);
printf("%s", ch);
}

A. Hello
B. World
C. Compilation error
D. Hello World
Answer : B
8. = and = = have the same operation.
A. True
B. False
C.
D.
Answer : B
9. 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
10. Which header file is essential for using strcmp() function?
A. string.h
B. strings.h
C. text.h
D. strcmp.h
Answer : A
11. printf() is not a library function.
A. True
B. False
C.
D.
Answer : B
12. The same variable names of automatic type can be used in different functions without any conflict.
A. True
B. False
C.
D.
Answer : A
13. # define PI = 8;' is the correct declaration of macros.
A. True
B. False
C.
D.
Answer : B
14. A declaration float a, b; occupies ___ of memory
A. 1 byte
B. 4 bytes
C. 8 bytes
D. 16 bytes
Answer : C
15. The default initial value of automatic storage class is 0.
A. True
B. False
C.
D.
Answer : B
16. ------ is the ternary operator
A. ?,-
B. ?,:
C. ++<--
D. none of the above
Answer : B
17. The expression "int i = j = k = 0;" is invalid.
A. True
B. False
C.
D.
Answer : A
18. When a user defined function is defined in program, then it has to be called at least once from the main().
A. True
B. False
C.
D.
Answer : B
19. 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
20. 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
21. 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
22. printf("%d", sizeof('2')); will print 2.
A. True
B. False
C.
D.
Answer : B
23. Single operations involving entire arrays are permitted in C.
A. True
B. False
C.
D.
Answer : A
24. /* The C language.
/* is a procedural language .*/*/
The above statement is valid.

A. True
B. False
C.
D.
Answer : B
25. 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
26. The size of signed integer is ------ bytes.
A. 4
B. 2
C. 8
D. 10
Answer : B
27. What's wrong? for (int k = 2, k <=12, k++)
A. the increment should always be ++k
B. the variable must always be the letter i when using a for loop
C. there should be a semicolon at the end of the statement
D. the commas should be semicolons
Answer : B
28. The output of the following code is:
main() 
{
unsigned int a = 10;
while (a>=10)
{
int a; a-- ;
}
printf("%i", a);
}

A. Infinite loop
B. 9
C. 0
D. None
Answer : A
29. enum helps to create user defined datatype.
A. True
B. False
C.
D.
Answer : A
30. static variable will not always have assigned value.
A. True
B. False
C.
D.
Answer : A
31. The function fopen() on failure returns---------------------.
A. 0
B. NULL
C. 1
D. none of the above
Answer : B
32. An array declared as A[100][100] can hold a maximum of 100 elements.
A. True
B. False
C.
D.
Answer : B
33. perror( ) function used to ?
A. Work same as printf()
B. prints the error message specified by the compiler
C. prints the garbage value assigned by the compiler
D. None of the above
Answer : B
34. Identify the wrong statement
A. putchar(65)
B. putchar('x')
C. putchar("x")
D. putchar('
')
Answer : C
35. Which of the following is invalid?
A. ''
B. " "
C. 'a'
D. abc'
Answer : D
36. When is std::bad_alloc exception thrown?
A. When new operator cannot allocate memory
B. When alloc function fails
C. When type requested for new operation is considered bad<  thisexception is thrown
D. When delete operator cannot delete teh allocated (corrupted) object
Answer : D
37. What's wrong? while( (i < 10) && (i > 24))
A. the logical operator && cannot be used in a test condition
B. the while loop is an exit-condition loop
C. the test condition is always true
D. the test condition is always false
Answer : D
38. 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
39. strcat() function ----------------------- two strings.
A. delete
B. concatenate
C. compare
D. none of the above
Answer : B
40. The output of the following code is:
main() 
{
int k, num = 30;
k = (num > 5 ? (num <= 10 ? 100 : 200) : 500);
printf("
%d", num);
}

A. 200
B. 500
C. 30
D. Unpredictable
Answer : C
41. There are total ------ numbers of operators in 'C'.
A. 35
B. 45
C. 55
D. 40
Answer : B
42. Which of the following is allowed in a C Arithmetic instruction
A. []
B. {}
C. ()
D. None of the above
Answer : C
43. The statement "for (i = 0, j = 2; j <= 10; j++)" is a valid statement in 'C'.
A. True
B. False
C.
D.
Answer : A
44. What will be output if you will compile and execute the following c code?
#include 
int main(){
int i=320;
char *ptr=(char *)&i;
printf("%d",*ptr);
return 0;
}

A. 1
B. 64
C. 320
D. Compiler Error
Answer : B
45. Variables declared as register storage type gets stored in CPU registers.
A. True
B. False
C.
D.
Answer : A
46. The -------------------------- loop executes at least once.
A. for
B. while
C. do-while
D. while & do-while
Answer : C
47. The output of the following code is:
main() 
{
int a = 0;
for (; i = 0; i++)
printf("%d", a);
}

A. 0
B. Nothing will be displayed
C. Infinite loop
D. None of the above
Answer : D
48. C programs are converted into machine language with the help of
A. An Editor
B. A compiler
C. An operating system
D. None of the above
Answer : B
49. emp name' is a valid variable name.
A. True
B. False
C.
D.
Answer : B
50. 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

Sharing is caring