Home

C Programming MCQ Solved Paper for NMAT

Thursday 9th of March 2023

Sharing is caring

1. The value of an enumerated datatype can be read using scanf() function.
A. True
B. False
C.
D.
Answer : B
2. C programming language was developed by
A. Dennis Ritchie
B. Ken Thompson
C. Bill Gates
D. Peter Norton
Answer : A
3. do-while loop is useful when we want the statements within the loop must be executed
A. Only once
B. At least once
C. More than Once
D. Any one of the above
Answer : B
4. 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
5. Which options shows the correct hierarchy of arithmetic operators
A. **, * or /, + or -
B. **, *, /, +, -
C. **< /< *< +<-
D. / or *, - or +
Answer : D
6. Nested macros are allowed.
A. True
B. False
C.
D.
Answer : B
7. gets() and puts() are unformatted I/O functions.
A. True
B. False
C.
D.
Answer : A
8. /* The C language.
/* is a procedural language .*/*/
The above statement is valid.

A. True
B. False
C.
D.
Answer : B
9. unsigned' is a valid variable name.
A. True
B. False
C.
D.
Answer : B
10. 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
11. The expression (i + j)++ is illegal.
A. True
B. False
C.
D.
Answer : A
12. There are total ------ numbers of operators in 'C'.
A. 35
B. 45
C. 55
D. 40
Answer : B
13. A recursive function calls itself again and again.
A. True
B. False
C.
D.
Answer : A
14. Which of the following is not a preprocessor directive
A. #if
B. #elseif
C. #undef
D. #pragma
Answer : B
15. The contents of a file opened in 'r+' mode cannot be changed.
A. True
B. False
C.
D.
Answer : B
16. char *s[10] defines an array of ------------------------
A. pointers to strings
B. string to pointer
C. both
D.
Answer : A
17. Which one of the following is not a fundamental data type in C++
A. float
B. string
C. int
D. wchar_t
Answer : A
18. 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
19. void' is a datatype.
A. True
B. False
C.
D.
Answer : A
20. 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
21. The main() function can be called from any other function.
A. True
B. False
C.
D.
Answer : A
22. The statement "for (i = 0, j = 2; j <= 10; j++)" is a valid statement in 'C'.
A. True
B. False
C.
D.
Answer : A
23. The output of the following code is:
void main() 
{
char a = 'B';
switch (a)
{
case 'A' : printf("a");
case 'B' : printf("b");
default : printf("c");
}

A. B
B. b
C. bca
D. bc
Answer : D
24. Which of the following language is predecessor to C Programming Language?
A. A
B. B
C. BCPL
D. C++
Answer : B
25. # define PI = 8;' is the correct declaration of macros.
A. True
B. False
C.
D.
Answer : B
26. All macro substitutions in a program are done before compilation of the program.
A. True
B. False
C.
D.
Answer : A
27. Bitwise operators can operate upon?
A. double and chars
B. floats and doubles
C. ints and floats
D. ints and chars
Answer : D
28. unsigned char has a range from 0 to ------------
A. 253
B. 254
C. 255
D. 256
Answer : C
29. 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
30. Which header file is essential for using strcmp() function?
A. string.h
B. strings.h
C. text.h
D. strcmp.h
Answer : A
31. 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
32. Which among the following is a unconditional control structure
A. do-while
B. if-else
C. goto
D. for
Answer : C
33. 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
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. The function fopen() on failure returns---------------------.
A. 0
B. NULL
C. 1
D. none of the above
Answer : B
36. The-------------------- statement helps immediate exit from any part of the loop
A. break
B. continue
C. exit
D. All of the above
Answer : A
37. Expression 4**3 evaluates to 64.
A. True
B. False
C.
D.
Answer : B
38. 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
39. ------ is the ternary operator
A. ?,-
B. ?,:
C. ++<--
D. none of the above
Answer : B
40. What is C Tokens?
A. The smallest individual units of c program
B. The basic element recognized by the compiler
C. The largest individual units of program
D. A & B Both
Answer : D
41. Single operations involving entire arrays are permitted in C.
A. True
B. False
C.
D.
Answer : A
42. A C variable cannot start with
A. An alphabet
B. A number
C. A special symbol other than underscore
D. both (b) and (c)
Answer : D
43. 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
44. The output of the following code is:
main() 
{
xyz: goto abc;
printf("Hello");
abc: printf("World");
goto xyz;
}

A. Infinite loop
B. Hello World
C. World Hello
D. Compilation error
Answer : A
45. Every if statement can be converted into an equivalent switch statement.
A. True
B. False
C.
D.
Answer : B
46. The printf() function retunes which value when an error occurs?
A. Positive value
B. Zero
C. Negative value
D. None of these
Answer : C
47. 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
48. An array elements are always stored in _________ memory locations.
A. Sequential
B. Random
C. Sequential and Random
D. None of the above
Answer : A
49. The expression "int i = j = k = 0;" is invalid.
A. True
B. False
C.
D.
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