Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests - Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests -

C Programming MCQs

C programming is a powerful programming language mainly used to code operating systems. Some of the advantages of C programming are listed below:

  • Fast
  • Portability
  • Structured Programming Language
  • Mid-Level Programming Language
  • Easy to understand

MCQs on C Programming

Solve C Programming MCQ Questions to prepare better for your GATE exams. We also advise the aspirants to solve previous years’ question papers and gauge the pattern of C MCQ questions by solving mock tests and checking notes. Meanwhile, check the C language MCQs that we have compiled below:

C Programming MCQ Questions

1. Determine the output of the C code mentioned below:

#include <stdio.h>

int main()

{

float q = ‘a’;

printf(“%f”, q);

return 0;

}

a. run time error

b. a

c. 97.000000

d. a.0000000

Answer: (c) 97.000000

2. Which of these is NOT a relational or logical operator?

a. =

b. ||

c. ==

d. !=

Answer: (a) =

3. What will be the output of the following C code?

#include<stdio.h>

int main()

{

int p = 1, q = 2, r = 3, s = 4, x;

e = r + s = q * p;

printf(“%d, %d\n”, x, s);

}

a. Syntax error

b. 5, 2

c. 7, 2

d. 7, 4

Answer: (a) Syntax error

4. Out of the following, which one is not valid as an if-else statement?

a. if ((char) x){}

b. if (x){}

c. if (func1 (x)){}

d. if (if (x == 1)){}

Answer: (d) if (if (x == 1)){}

5. We cannot use the keyword ‘break’ simply within _________.

a. while

b. for

c. if-else

d. do-while

Answer: (c) if-else

6. The output of the C code mentioned below would be:

#include <stdio.h>

int main()

{

int a = 0, b = 0;

l1: while (a < 2)

{

a++;

while (b < 3)

{

printf(“find\n”);

goto l1;

}

}

}

a. loop loop find loop

b. Infinite error

c. find loop

d. Compile time loop

Answer: (c) find loop

7. The global variables are ____________.

a. External

b. Internal

c. Both External and Internal

d. None of the above

Answer: (a) External

8. Out of the following operations, which one is not possible in the case of a register variable?

a. Global declaration of the register variable

b. Copying the value from the memory variable

c. Reading any value into the register variable

d. All of the above

Answer: (d) All of the above

9. The #include <stdio.h> is a ______________.

a. Inclusion directive

b. File inclusion directive

c. Preprocessor directive

d. None of the above

Answer: (c) Preprocessor directive

10. Which of these properties of #define is false?

a. These always obey the scope rules

b. We can make use of a pointer to #define

c. The #define can be externally available

d. All of the above

Answer: (d) All of the above

11. The correct format of declaring a function is:

a. type_of_return name_of_function (argument type);

b. type_of_return name_of_function (argument type){}

c. type_of_return (argument type) name_of_function;

d. all of the above

Answer: (a) type_of_return name_of_function (argument type);

12. Out of the following function definition, which one will run correctly?

a.

int sum(int x, int y)

return (x + y);

b.

int sum(int x, int y)

{return (x + y);}

c.

int sum(x, y)

return (x + y);

d. none of the above

Answer: (b)

int sum(int x, int y)

{return (x + y);}

13. Comment on the C statement given below:

int (*p)[5];

a. A ragged array

b. An array “p” of pointers

c. A pointer “p” to an array

d. None of the above

Answer: (c) A pointer “p” to an array

14. The output of the C code mentioned below would be:

#include <stdio.h>

struct employee

{

int id;

char rank[5];

}

void main()

{

struct employee e;

s.no = 30;

printf(“howdy”);

}

a. hello

b. Compile-time error

c. 5, 30

d. Varies

Answer: (b) Compile-time error

15. We can test the presence of a loop in a linked list by ________.

a. Comparing the node’s address with the address of all the other nodes

b. Travelling the list. In case we encounter the NULL, then no loop exists

c. Comparing the stored values of a node with the values present in all the other nodes

d. None of the above

Answer: (a) Comparing the node’s address with the address of all the other nodes

16. Determine what’s true for x, if we define x as “int *x[10];”?

a. This definition will only allocate 10 pointers but will not initialize them

b. The initialization must be explicitly performed

c. The definition will only allocate 10 pointers but will not initialize them. Also, the initialization has to be explicitly performed

d. Error

Answer: (c) The definition will only allocate 10 pointers but will not initialize them. Also, the initialization has to be explicitly performed

17. Which of these is the correct initialization method for the following:

typedef char *string;

a. More than a single space shouldn’t be given when we are using typedef

b. *string p = ‘A’;

c. string p = “Hello”;

d. *string *p = “Hello”;

Answer: (c) string p = “Hello”;

18. We can determine the size of a union with the help of the size of __________.

a. The sum of all the members’ sizes

b. The biggest member of the union

c. The last member of the union

d. The first member of the union

Answer: (b) The biggest member of the union

19. How much percentage of memory will be saved if we use bit-fields for the given C structure as compared to when we don’t use bit-fields for this very structure? (Assume the size of int to be 4).

struct temp

{

int m : 1;

int n : 2;

int o : 4;

int p : 4;

}s;

a. 33.3%

b. 75%

c. 25%

d. 50%

Answer: (b) 75%

20. Out of the following snippet, which one will generate random numbers effectively?

a. rand(time(NULL));

b. rand(10);

c. rand();

d. all of the above

Answer: (c) rand();

21. We can achieve the modulus for float by:

a. x % y

b. modulus(x, y);

c. fmod(x, y);

d. mod(x, y);

Answer: (c) fmod(x, y);

22. __________ tells a compiler that the data would be defined somewhere and it would be connected to the linker.

a) variable

b) yvals

c) errno

d) extern

Answer: (d) extern

23. The definition of the function abort() is in which header file?

a) stdlib.h

b) assert.h

c) stdio.h

d) stdarg.h

Answer: (a) stdlib.h

24. What is the primary purpose of the preprocessor directive #error?

a) Rectifies the first error occuring in the code

b) Rectifies the errors present in a code

c) Causes a preprocessor to ignore any error

d) Causes a preprocessor to report some fatal error

Answer: (d) Causes a preprocessor to report some fatal error

25. _____________ is a condition in which the memory is dynamically reserved but isn’t accessible to any program.

a) Pointer Leak

b) Frozen Memory

c) Dangling Pointer

d) Memory Leak

Answer: (a) Memory Leak

Keep learning and stay tuned to get the latest updates on the GATE Exam along with Eligibility Criteria, GATE Syllabus for CSE (Computer Science Engineering), GATE CSE Notes, GATE CSE Question Paper, and more.

Comments

Leave a Comment

Your Mobile number and Email id will not be published.

*

*