Home

CLAT PG - C Programming 1000+ MCQ [Solved] PDF Download

Thursday 9th of March 2023

Sharing is caring

1. The array 'char name[10] can consist of a maximum of 9 characters.
A. True
B. False
C.
D.
Answer : A
2. The output of the following code is:
main() 
{
int a[10], i;
for (i = 1; I <= 0; i++)
{
scanf("%d", a[i]);
printf("%d", a[i]);
}
}

A. 10
B. Logical error
C. Runtime error
D. 1 to 10 will be displayed
Answer : B
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 C language.
/* is a procedural language .*/*/
The above statement is valid.

A. True
B. False
C.
D.
Answer : B
5. 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
6. The size of signed integer is ------ bytes.
A. 4
B. 2
C. 8
D. 10
Answer : B
7. printf() is not a library function.
A. True
B. False
C.
D.
Answer : B
8. The expression (i + j)++ is illegal.
A. True
B. False
C.
D.
Answer : A
9. The output of the following code is:
void main() 
{
static int a = 1, b, c;
if (a>=2) b=2; c=3;
printf("%d\t%d", b,c);
}

A. 2 3
B. 0 3
C. 0 0
D. 2 0
Answer : B
10. 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
11. 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
12. Variables declared as register storage type gets stored in CPU registers.
A. True
B. False
C.
D.
Answer : A
13. An array elements are always stored in _________ memory locations.
A. Sequential
B. Random
C. Sequential and Random
D. None of the above
Answer : A
14. char *s[10] defines an array of ------------------------
A. pointers to strings
B. string to pointer
C. both
D.
Answer : A
15. Which of the following is not true about preprocessor directives
A. They begin with a hash symbol
B. They are processed by a preprocessor
C. They form an integral part of the code
D. They have to end with a semi colon
Answer : A
16. The expression 'int j = 6 + 3 % -9;' evaluates to -1.
A. True
B. False
C.
D.
Answer : B
17. 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
18. 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
19. unsigned char has a range from 0 to ------------
A. 253
B. 254
C. 255
D. 256
Answer : C
20. unsigned' is a valid variable name.
A. True
B. False
C.
D.
Answer : B
21. Which options shows the correct hierarchy of arithmetic operators
A. **, * or /, + or -
B. **, *, /, +, -
C. **< /< *< +<-
D. / or *, - or +
Answer : D
22. 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
23. 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
24. A declaration float a, b; occupies ___ of memory
A. 1 byte
B. 4 bytes
C. 8 bytes
D. 16 bytes
Answer : C
25. Which header file is essential for using strcmp() function?
A. string.h
B. strings.h
C. text.h
D. strcmp.h
Answer : A
26. 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
27. How many times the following loop will execute?
for (a = 0; a < 4; a++)
printf("hello
");

A. 3
B. 4
C. 5
D. infinite
Answer : B
28. The contents of a file opened in 'r+' mode cannot be changed.
A. True
B. False
C.
D.
Answer : B
29. 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
30. 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
31. Left shift operator rotates the bits on the left and places them to the right.
A. True
B. False
C.
D.
Answer : B
32. 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
33. static variable will not always have assigned value.
A. True
B. False
C.
D.
Answer : A
34. continue statement is used
A. to go to the next iteration in a loop
B. come out of a loop
C. exit and return to the main function
D. restarts iterations from beginning of loop
Answer : D
35. An array declared as A[100][100] can hold a maximum of 100 elements.
A. True
B. False
C.
D.
Answer : B
36. Which classes allow primitive types to be accessed as objects?
A. Storage
B. Virtual
C. Friend
D. Wrapper
Answer : B
37. A recursive function calls itself again and again.
A. True
B. False
C.
D.
Answer : A
38. In the expression - 'x + y + 3z =20'
A. x + y' is a keyword
B. 3 and 20 are constants
C. 3z is a constant
D. y is a variable and z is a constant
Answer : B
39. 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
40. 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
41. 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
42. 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
43. 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
44. emp name' is a valid variable name.
A. True
B. False
C.
D.
Answer : B
45. Which of the following is allowed in a C Arithmetic instruction
A. []
B. {}
C. ()
D. None of the above
Answer : C
46. What is the difference between overloaded functions and overridden functions?
A. Overloading is a dynamic or run-time binding and Overriding is static or compile-time binding
B. Redefining a function in a friend class is called function overriding while Redefining a function in a derived class is called a overloaded fucntion.
C. Overloading is a static or compile-time binding and Overriding is dynamic or run-time binding
D. Redefining a function in a friend class is called function overloading while Redefining a function in a derived class is called as overridden fucnion.
Answer : B
47. What would be the output of the following program?
int x=40;
main(){
int x=20;
printf("
%d",x);
}

A. 40
B. 20
C. Compilation Error
D. Garbeg Value
Answer : B
48. 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
49. Identify the wrong statement
A. putchar(65)
B. putchar('x')
C. putchar("x")
D. putchar('
')
Answer : C
50. The identifier argv[] is a pointer to an array of strings.
A. True
B. False
C.
D.
Answer : B

Sharing is caring