0% found this document useful (0 votes)
47 views11 pages

1 - C Lang - MCQ

Uploaded by

pragya.singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views11 pages

1 - C Lang - MCQ

Uploaded by

pragya.singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

1. What is the primary function of a programming language?

a) Displaying web pages

b) Interacting with databases

c) Controlling computer hardware

d) Analyzing data

Answer: c) Controlling computer hardware

2. Which of the following is NOT a high-level programming language?

a) C

b) Python

c) Assembly

d) Java

Answer: c) Assembly

3. What is the purpose of a variable in C?

a) To represent a constant value

b) To store and manipulate data during program execution

c) To perform mathematical calculations

d) To control program flow

Answer: b) To store and manipulate data during program execution


4. Which symbol is used to declare a single-line comment in C?

a) //

b) #

c) /*

d) """

Answer: a) //

5. Which data type is used to store whole numbers in C?

a) int

b) float

c) char

d) double

Answer: a) int

6. What is the size of the 'int' data type in C?

a) 4 bytes

b) 2 bytes

c) 8 bytes

d) It varies depending on the platform

Answer: d) It varies depending on the platform

7. Which data type is used to store characters in C?


a) char

b) int

c) float

d) double

Answer: a) char

8. Which keyword is used to declare a constant in C?

a) var

b) constant

c) const

d) static

Answer: c) const

9. What is the size of the 'char' data type in C?

a) 1 byte

b) 2 bytes

c) 4 bytes

d) It varies depending on the platform

Answer: a) 1 byte

10. Which data type is used to store real numbers with single precision in C?

a) float
b) double

c) long double

d) real

Answer: a) float

11. What is the size of the 'float' data type in C?

a) 4 bytes

b) 8 bytes

c) 2 bytes

d) It varies depending on the platform

Answer: a) 4 bytes

12. Which data type is used to store real numbers with double precision in C?

a) float

b) double

c) long double

d) real

Answer: b) double

13. What is the size of the 'double' data type in C?

a) 4 bytes

b) 8 bytes
c) 2 bytes

d) It varies depending on the platform

Answer: b) 8 bytes

14. What is the range of values that can be stored in an 'int' data type?

a) -32768 to 32767

b) 0 to 65535

c) -2147483648 to 2147483647

d) -128 to 127

Answer: c) -2147483648 to 2147483647

15. Which of the following is a valid variable name in C?

a) my variable

b) _count

c) 3nums

d) double

Answer: b) _count

16. Which operator is used to access the address of a variable in C?

a) &

b) *

c) $
d) #

Answer: a) &

17. Which of the following is a correct way to declare and initialize a variable in C?

a) int num;

b) var num;

c) num = 10;

d) int num = 10;

Answer: d) int num = 10;

18. What will be the output of the following code snippet?

```c

int x = 5;

printf("%d", x++);

```

a) 4

b) 5

c) 6

d) The code contains an error

Answer: b) 5

19. What is the output of the following code snippet?


```c

int a = 10, b = 3;

float result = a / b;

printf("%f", result);

```

a) 3.333333

b) 3.000000

c) 3.666667

d) 3

Answer: b) 3.000000

20. Which header file is required to perform input and output operations in C?

a) <stdio.h>

b) <iostream.h>

c) <io.h>

d) <inputoutput.h>

Answer: a) <stdio.h>

21. What will be the output of the following code snippet?

```c

int num = 7;

printf("%d", num / 2);

```
a) 3.5

b) 3.0

c) 3

d) 2.5

Answer: c) 3

22. Which data type is used to store true/false values in C?

a) boolean

b) bool

c) int

d) char

Answer: b) bool

23. What will be the output of the following code snippet?

```c

char ch = 'A';

printf("%c", ch + 1);

```

a) A

b) B

c) C

d) The code contains an error


Answer: b) B

24. Which data type is used to store a single character in C?

a) char

b) int

c) string

d) character

Answer: a) char

25. What will be the output of the following code snippet?

```c

int x = 10, y = 5;

printf("%d", x % y);

```

a) 2

b) 5

c) 0

d) 1

Answer: c) 0

26. Which keyword is used to declare a function in C?

a) function

b) method
c) fun

d) void

Answer: d) void

27. What is the purpose of the 'return' statement in a C function?

a) To terminate the program

b) To return a value from the function

c) To print output on the screen

d) To declare a variable

Answer: b) To return a value from the function

28. What is the output of the following code snippet?

```c

int x = 5;

printf("%d", ++x);

```

a) 4

b) 5

c) 6

d) The code contains an error

Answer: c) 6
29. Which of the following is a correct way to declare a constant pointer in C?

a) int *const ptr;

b) const int *ptr;

c) const int *const ptr;

d) int const *ptr;

Answer: c) const int *const ptr;

30. What is the size of the 'long double' data type in C?

a) 4 bytes

b) 8 bytes

c) 16 bytes

d) It varies depending on the platform

Answer: d) It varies depending on the platform

Please note that these questions are for educational purposes and may vary based on the C

You might also like