C Programming MCQ with answers PDF [260 Question]

C Programming MCQ with answers PDF. Procedural Language Important Theory Questions for all computer competitive exams (TCS, GATE, CDAC, AMCAT, O level, ZOHO etc.) and interview Preparation Multiple choice and Objective Type Basic to Advance level MCQs.

C Programming MCQ with Answers PDF

1 – Which of the following is used in mode string to open the file in binary mode?

A – a              

B – b              

C – B             

D – bin

Answer : B

Explanation: To perform unformatted data I/O a file is opened in binary mode and is represented with the alphabet ‘b’ in the mode string.

2 – A local variable is stored in ___

A – Code segment

B – Stack segment

C – Heap segment

D – None of the above

Answer : B

Explanation: All the local variables are stored in a memory called as stack.

3 – In C, what are the various types of real data type (floating point data type)?

A – Float, long double

B – long double, short int

C – float, double, long double

D – short int, double, long int, float

Answer : C

Explanation: There are three types of floating point data type

1) float with storage size 4 byte,

2) double with storage size 8 byte, and

3) long double with storage size 10 byte.

4 – For a structure, if a variable behave as a pointer then from the given below operators which operator can be used to access data of the structure via the variable pointer?

A – .

B – %

C – ->

D – #

Answer : C

Explanation: For a structure, Dot(.) operator can be used to access the data using normal structure variable and arrow (->)can be used to access the data using pointer variable.

5 – Why to use fflush() library function?

A – To flush all streams and specified streams

B – To flush only specified stream

C – To flush input/output buffer

D – Invalid library function

Answer : A

Explanation: In C programming, the fflush() function writes any unwritten data in stream’s buffer. If, stream is a null pointer, fflush() function will flush all streams with unwritten data in the buffer.

int fflush(FILE *stream);

6. What does this declaration mean?

int x : 4;

a) x is a four-digit integer.

b) x cannot be greater than a four-digit integer

c) x is a four-bit integer

d) None of these

Ans. C

7. Why is a macro used in place of a function?

a) It reduces execution time.         

b) It reduces code size.

c) It increases execution time.      

d) It increase code size

Ans. B

8. In the C language, the constant is defined ____.

a) Before main

b) After main

c) Anywhere, but starting on a new line

d) None of these

Ans. C

9. How many times will the following loop execute?

for(j=1; j<=10; j=j-1)

a) Forever

b) Never

c) 0

d) 1

Ans. A

10. Which one of the following is a loop construct that will always be executed once?

a) for

b) while

c) switch

d) do while

Ans. D

11. Directives are translated by the

a) Pre-processor

b) Compiler

c) Linker

d) Editor

Ans. A

12. How many bytes does “int=D” use?

a) 0

b) 1

c) 2 or 4

d) 10

Ans. C

13. What feature makes C++ so powerful?

a) Easy implementation                 

b) Reusing the old code

c) Easy memory management      

d) All of the above

Ans. D

14. Which of the following will copy the null-terminated string that is in array src into array dest?

a) dest = src;

b) dest == src;

c) strcpy(dest, src);

d) strcpy(src, dest);

Ans. C

15. Each instance of a class has a different set of

a) Class interfaces              

b) Methods

c) Return types                    

d) Attribute values

Ans. D

16. How many instances of a class can be declared?

a) 1

b) 10

c) As per required

d) None of these

Ans. C

17. What will the result of num variable after execution of the following statements?

int num = 58;

num % = 11;

a) 3

b) 5

c) 8

d) 11

Ans. A

Explanation: num % = 11

num = num % 11

num = 58 % 11

num = 3

18. Which of the following statement is not true?

a) a pointer to an int and a pointer to a double are of the same size

b) A pointer must point to a data item on the head (free store)

c) A pointer can be reassigned to point to another data item.

d) A pointer can point to an array.

Ans. B

19. Which of the following SLT template class is a container adaptor class?

a) Stack

b) List

c) Deque

d) Vector

Ans. A

20. What kinds of iterators can be used with vectors?

a) Forward iterator

b) Bi-directional iterator

c) Random access iterator

d) All of the above

Ans. D

21. The following statements are about EOF. Which of them is true?

a) Its value is defined within stdio.h

b) Its value is implementation dependent

c) Its value can be negative

d) Its value should not equal the integer equivalent of any character

d) All of these

Ans. D

22. For 16-bit compiler allowable range for integer constants is ______?

a) -3.4e38 to 3.4e38

b) -32767 to 32767

c) -32668 to 32668              

d) -32768 to 32768

Ans. D

23. C programs are converted into machine language with the help of

a) An Editor

b) A compiler

c) An operating system

d) None of these

Ans. B

24. C was primarily developed as

a) System programming language

b) General purpose language

c) Data processing language

d) None of the above

Ans. A

25. Which one of the following is not  a reserved keyword for C ?

a) auto

b) case

c) main

d) default

Ans. C

26. Which one of the following is not a valid identifier?

a) _sonu

b) 1sonu

c) sonu

d) sonu1

Ans. B

27. What is the correct value to return to the operating system upon the successful completion of a program?

a) 1

b) -1

c) 0

d) Program do not return value

Ans. C

28. Which of the following is not a correct variable type?

a) float           

b) real

c) int              

d) double

Ans. B

29. Which of the following is not a valid name for a C variable?

a) GKEDITORIAL    

b) GK_EDITORIAL

c) GK EDITORIAL   

d) Both A and B

Ans. C

30. What is the difference between a declaration and a definition of a variable?

a) Both can occur multiple times, but a declaration must occur first

b) A definition occurs once, but a declaration may occur many times.

c) Both can occur multiple times, but a definition must occur first

d) A declaration occurs once, but a definition may occur many times.

Ans. D

31. “My salary was increased by 15%” select the statement, which will EXACTLY reproduce the line of text above.

a) printf(“My salary was increased by 15/%!”);

b) printf(“My salary was increased by 15%!”);

c) printf(“My salary was increased by 15’%!”);

d) printf(“My salary was increased by 15%%!”);

Ans. D

32. An array element are always stored in _____ memory locations.

a) Sequential

b) Random

c) Sequential and Random

d) None or the above

Ans. A

33. What is the maximum number of dimensions an array in C may have?

a) 2

b) 8

c) 20

d) Theoratically no limit. The only practical limits are memory size and compilers.

Ans. D

34. Size of the array need to be specified, when

a) Initialization is a part of definition

b) It is a declaration

c) It is a formal parameter

d) All of these

Ans. D

35. Array passed as an argument to a function is interpreted as

a) Address of the array

b) Values of the first elements of the array

c) Address of the first element of the array

d) Number of element of the array.

Ans. C

36. If the two strings are identical, then strcmp() function returns

a) 1

b) 0

c) -1

d) true

Ans. B

37. The library function used to find the last occurrence of a character in a string is

a) laststr()      

b) strstr()

c) strnstr()     

d) strrchr()

Ans. D

38. Which of the following function is used to find the first occurrence of a given string in another string?

a) strchr()      

b) strrchr()

c) strstr()        

d) strnset()

Ans. C

39. Which of the following function is more appropriate for reading in a multi-word string?

a) scanf()

b) gets()

c) printf()

d) puts()

Ans. B

40. Which of the following correctly accessed the seventh element stored in arr, an array with 100 elements?

a) arr[6]

b) arr[7]

c) arr{6}

d) arr{7}

Ans. A

C Programming MCQ with answers PDF [Download] 260 Question
Best Computer MCQ Book for Competitive Exams [7000 MCQs]
WhatsApp Channel Join Now
Telegram Channel Join Now
Instagram Page Join Now