Home

C Programming MCQ Solved Paper for IIFT

Thursday 9th of March 2023

Sharing is caring

1. 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
2. Which of the following shows the correct hierarchy of arithmetic operations in C
A. / + * ?
B. * ? / +
C. + ? / *
D. * / + -
Answer : D
3. The output of the following code is:
void main() 
{
float a;
int x = 10, y = 3; a = x / y;
printf("%f", a); }

A. 3.999999
B. Error
C. 3
D. 3.000000
Answer : D
4. 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
5. The value of an enumerated datatype can be read using scanf() function.
A. True
B. False
C.
D.
Answer : B
6. The-------------------- statement helps immediate exit from any part of the loop
A. break
B. continue
C. exit
D. All of the above
Answer : A
7. unsigned char has a range from 0 to ------------
A. 253
B. 254
C. 255
D. 256
Answer : C
8. 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
9. Each pass through a loop is called a/an
A. enumeration
B. iteration
C. culmination
D. pass through
Answer : C
10. The array 'char name[10] can consist of a maximum of 9 characters.
A. True
B. False
C.
D.
Answer : A
11. 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
12. 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
13. The expression 'int j = 6 + 3 % -9;' evaluates to -1.
A. True
B. False
C.
D.
Answer : B
14. The expression "int i = j = k = 0;" is invalid.
A. True
B. False
C.
D.
Answer : A
15. 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
16. 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
17. Expression 4**3 evaluates to 64.
A. True
B. False
C.
D.
Answer : B
18. The identifier argv[] is a pointer to an array of strings.
A. True
B. False
C.
D.
Answer : B
19. All macro substitutions in a program are done before compilation of the program.
A. True
B. False
C.
D.
Answer : A
20. An array elements are always stored in _________ memory locations.
A. Sequential
B. Random
C. Sequential and Random
D. None of the above
Answer : A
21. It is necessary to initialize the array at the time of declaration.
A. True
B. False
C.
D.
Answer : B
22. 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
23. 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
24. Which of the following correctly describes C++ language?
A. Statically typed language
B. Dynamically typed language
C. Both Statically and dynamically typed language
D. Type-less language
Answer : D
25. Nested macros are allowed.
A. True
B. False
C.
D.
Answer : B
26. Character data types cannot be declared as unsigned.
A. True
B. False
C.
D.
Answer : B
27. The output of the following code is:
main() 
{
int sub[50];
for(i=0; i<=48;i++)
{
sub[i]=i;
printf("
%d", sub[i]);
}
}

A. 0 to 48 will be displayed
B. 48
C. 49
D. Compilation Error
Answer : D
28. Which of the following language is predecessor to C Programming Language?
A. A
B. B
C. BCPL
D. C++
Answer : B
29. There are total ------ numbers of operators in 'C'.
A. 35
B. 45
C. 55
D. 40
Answer : B
30. 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
31. A pointer is an indication of the variable to be accessed next.
A. True
B. False
C.
D.
Answer : B
32. Which one of the following is not a valid reserved keyword in C++
A. Explicit
B. Public
C. Implicit
D. Private
Answer : C
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. Which of the following is not a preprocessor directive
A. #if
B. #elseif
C. #undef
D. #pragma
Answer : B
35. char *s[10] defines an array of ------------------------
A. pointers to strings
B. string to pointer
C. both
D.
Answer : A
36. The printf() function retunes which value when an error occurs?
A. Positive value
B. Zero
C. Negative value
D. None of these
Answer : C
37. The expression (i + j)++ is illegal.
A. True
B. False
C.
D.
Answer : A
38. 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
39. The expression "b = 3 ^ 2;" will evaluate b = 9.
A. True
B. False
C.
D.
Answer : B
40. 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
41. emp name' is a valid variable name.
A. True
B. False
C.
D.
Answer : B
42. Which among the following is a unconditional control structure
A. do-while
B. if-else
C. goto
D. for
Answer : C
43. = and = = have the same operation.
A. True
B. False
C.
D.
Answer : B
44. Left shift operator rotates the bits on the left and places them to the right.
A. True
B. False
C.
D.
Answer : B
45. Structures within structures cannot be created.
A. True
B. False
C.
D.
Answer : B
46. 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
47. Which of the following is invalid?
A. ''
B. " "
C. 'a'
D. abc'
Answer : D
48. # define PI = 8;' is the correct declaration of macros.
A. True
B. False
C.
D.
Answer : B
49. Which of the following is allowed in a C Arithmetic instruction
A. []
B. {}
C. ()
D. None of the above
Answer : C
50. The main() function can call itself recursively.
A. True
B. False
C.
D.
Answer : A

Sharing is caring