GATE Exam » GATE MCQs » C Programming MCQs

C Programming MCQs

This article will discuss important points about C programming and will as mention multiple choice questions on the topic of C Programming. The article will further explain the answers to each question in brief. Further questions related to the various section under C programming can be found all throughout the article.

What is an operating system?

C seems to have been originally developed as a simple programming language that helped in building operating systems that were later used in minicomputers like the DEC PDP 7, which seemed to contain minimal memory capacity when compared to mainframe machines at the time. The development of c programming began in the 1970s with the help of a language called CPL. The c language was similar and had reference to CPL, which is commonly known as a combined programming language; the CPL was a language that was developed by Ken Thompson. The development of CPL was around 1969–70. Ritchie, a colleague of Thompson, further developed the CPL language, then redesigned as well as restored common important CPU features and developed a new functioning language called C, and afterward recreated the UNIX OS with the new language.

Multiple Choice Questions (MCQs)

Q1. Which of the following is an important requirement of c programming?

  1. Function
  2. Input variables
  3. Output variables
  4. All of the above

Answer: a) function. Every c programming needs at least one function as they facilitate the whole programming process. The functions seem to act as a subprogram within the whole c programming procedure. Functions can be crucial as they contain various variables that need to be reused multiple times.

Q2. Which of the following is true in the case of c programming?

  1. The function is a variable.
  2. Parenthesis isn’t needed at all in c programming.
  3. There is no need for closing parenthesis in c programming
  4. Float is a variable.

Answer: d)Float is a variable. The float seems to be a type of variable associated with c programming and multiple other programming languages. Variables can be of different types, such as int, char, double, float, etc.

Q3. When was C programming developed?

  1. The 1950s
  2. The 1960s
  3. The 1980s
  4. The 1970s

Answer: d) the 1970s. The C programming language was developed by a scientist called Dennis M. Ritchie. He developed the c programming language around the 1970s after taking references from a computer language known as a combined programming language (CPL). 

Q4. What was C programming adapted from?

  1. C++
  2. Combined programming language
  3. python
  4. All of the above

Answer: b) combined programming language(CPL). C programming was developed with the help of a language called combined programming language, which was developed by a scientist named Ken Thompson. He was a colleague of Ritchie, who was the developer of the C programming language.

Q5. Which of the following is not a variable type in c programming?

  1. Float
  2. Int
  3. While loop
  4. All of the above

Answer. c) While loop. The float and int are commonly used variable types, and the while loop seems to be a specific type of programming language that has no properties of a variable and helps in scenarios where a program needs to run in loops.

Q6. What is the use of print f in c programming?

  1. Helps in the printing of a string on the output screen
  2. Processes the variables in a program
  3. Is a variable type
  4. All of the above

Answer. b) Helps in the printing of strings on the output screen. The print f command seems to be used by users of c programming for printing outputs of string elements on the output screen. This is one of the most used commands as it helps in recognizing all the programming is done and its output. 

Q7. What are strings in C programming?

  1. Individual variables
  2. Group of function 
  3. Group of character type variables in array form 
  4. All of the above

Answer. c) Group of character type variables in array form. Strings are a group of variables that can be of character type as well as any other variable type. The strings can contain constant values as well as variables that can change over time. Strings have the property of containing a large number of arrays.

Q8. What does a do-while loop do?

  1. Repeats the process infinitely
  2. Processes the code at least once and then repeats
  3. Repeats only once
  4. All of the above

Answer. b) Processes the code at least once and then repeats. The do-while loop, unlike the while loop, executes the code within the loop at least once at the beginning and then enters the loop once again only if the boolean condition says so.

Q9. What is a while loop?

  1. Repeats the loop if the condition applies true
  2. Processes the code at least once and then repeats
  3. Repeats only once
  4. All of the above

Answer. a) repeats the code infinitely. The while loop, unlike the do-while loop, can only execute the code only if the boolean condition is satisfied, then can run infinitely if needed.

Q10. What of the following is true?

  1. Variables are functions
  2. Variable is a type of output command
  3. Variables are used to store values
  4. All of the above

Answer. c) Variables are used to store values. Variables are a type of memory that seems to store all the input values or unknown values generated during the coding procedure. It is used as a storing unit.

Q11. What are float variables?

  1. Integer value
  2. unknown value
  3. Decimal value
  4. All of the above

Answer. c) decimal value. The variables are of different types, and one of them is a float which has the properties of storing fraction values that are in decimal form. This helps in recording nonwhole numbers without any issue.

Q12. What is a function?

  1. Looping code
  2. Code that operates when called
  3. Unknown variable
  4. All of the above

Answer. b) Code that operates when called. The function seems to be a block of code that can only run when the function name is called upon by the code. It is usually used to run large chunks of code with one command called function calling.

Q13. How many variables can the following string contain bat[45]?

  1. 20
  2. 40
  3. 44
  4. 45

Answer. d) 45. As shown in the string mentioned as bat[45], the value 45 represents the number of distinct variables that the whole string can contain and execute in one instance.

Q14. What is function overloading?

  1. Process of multiple functions
  2. Multiple functions with the same name
  3. Looping functions
  4. All of the above

Answer. b) Multiple functions with the same name. The term function overloading is used when two or more functions have the same names. C programming has a property that allows two functions with the same name to exist at one time, but their variables need to be different.

Q15. Which header file uses gets()?

  1. Studio. h
  2. Stdlib.h
  3. Conio.h
  4. All of the above

Answer. c) conio.h. The getch() command is used to show the output screen for a while and is used to read single characters on a compiler screen, later resulting in exiting the console or terminal screen. The getch() falls under the conio.h header file and can only run on old compiler softwares.

Q16. Which of the following is the wrong way of writing c language?

  1. Int bat;
  2. Float cat_a;
  3. Int @rat
  4. All of the above

Answer. c) Int @rat. The variables can only be represented in the form of normal characters with an only underscore as an exception. No other type of special characters is allowed informing data types. So, in this case, @ cannot be used to represent int data type.

Q17. What are const data types used for?

  1. Unknown values
  2. Static or constant values
  3. Dynamic variable values
  4. All of the above

Answer. b) Static or constant values. The const data types are used for storing constant values that don’t have any requirements of change in their values in the near future. The const data type serves as a lock system for these values.

Q18. What are the primary iterations in C programming?

  1. While loop
  2. Do while loop
  3. For loop
  4. All of the above

Answer. d) all of the above. Iteration seems to be a process in c programming where a specific block of code runs on a constant of the controlled loop, and the whole process involves boolean conditions. All the major loops are a part of the iteration section.

Q19. Which of the following is not related to c programming?

  1. conio.h
  2. getch()
  3. console.log
  4. All of the above

Answer. c) console.log.The console.log seems to be a command that is used mainly in a computer programming language called javascript. All other mentioned options like float and getch are a part of c programming.

Q20. What is scanf() in c programming?

  1. The layout of an input string
  2. Array
  3. Output function
  4. All of the above

Answer. a) Layout of an input string. The scanf() seems to be used with functions that help in reading formatted input data and helps in categorizing them into various data types. The scanf() can help identify what kind of data type an input seems to be.