MCQs on Data Types and Variables | C Programming

Chapter 2 of C Programming introduces the essential concepts of data types and variables. This chapter covers the various data types in C, such as int, char, float, and double, which are used to store different kinds of information in a program. Understanding data types helps define the kind of data a variable can hold, ensuring proper memory allocation and data handling. Additionally, it explains how to declare and initialize variables, enabling programmers to store values effectively. This foundational knowledge of C variables and data types is crucial for building reliable and efficient C programs.

The best way to go through this MCQs collection is below:

  1. Take a sheet
  2. note down the answer options
  3. Finally compare with the answers at last and score yourself.

Chapter 2: Data Types and Variables

Data Types (int, char, float, double, etc.)

  1. Which data type is used to store whole numbers in C?
    • a) float
    • b) double
    • c) int
    • d) char
  2. What is the size of the int data type in most 32-bit compilers?
    • a) 2 bytes
    • b) 4 bytes
    • c) 8 bytes
    • d) 1 byte
  3. Which data type is used to store a single character?
    • a) char
    • b) float
    • c) double
    • d) int
  4. What is the typical size of a float data type?
    • a) 2 bytes
    • b) 4 bytes
    • c) 8 bytes
    • d) 1 byte
  5. Which data type would you use to store a large floating-point number with high precision?
    • a) int
    • b) char
    • c) double
    • d) float
  6. Which of the following is a floating-point data type?
    • a) int
    • b) char
    • c) double
    • d) long
  7. What is the value range of the char data type?
    • a) 0 to 127
    • b) -128 to 127
    • c) 0 to 255
    • d) -255 to 255
  8. What keyword is used to define a constant floating-point number?
    • a) const float
    • b) float const
    • c) double
    • d) const double
  9. Which data type would be the best choice for storing a person’s age?
    • a) int
    • b) float
    • c) double
    • d) char
  10. The size of which data type is dependent on the system architecture?
    • a) int
    • b) char
    • c) double
    • d) float

Variable Declaration and Initialization

  1. Which of the following is the correct way to declare an integer variable?
    • a) integer num;
    • b) int num;
    • c) num int;
    • d) var int num;
  2. What is the correct syntax to initialize a variable x with a value of 5?
    • a) x = 5;
    • b) int x = 5;
    • c) x := 5;
    • d) int := 5;
  3. Which of the following declares and initializes a variable in one line?
    • a) int x;
    • b) int x = 0;
    • c) x = 0;
    • d) initialize int x;
  4. If a variable is declared without initialization, its value is:
    • a) Zero
    • b) Garbage value
    • c) Default value
    • d) -1
  5. What is the initial value of an uninitialized float variable in C?
    • a) 0.0
    • b) Undefined
    • c) -1
    • d) Infinity
  6. Which symbol is used for assignment in C programming?
    • a) =
    • b) ==
    • c) :=
    • d) =:
  7. What is a variable in C?
    • a) A reserved word
    • b) A memory location
    • c) A constant value
    • d) A control structure
  8. Which of the following is not a valid variable name in C?
    • a) total_sum
    • b) 2total
    • c) totalSum
    • d) TotalSum
  9. Which keyword is used to declare a variable in C?
    • a) let
    • b) var
    • c) int
    • d) decl
  10. What is the correct way to update the value of an integer variable num to 10?
    • a) num = 10;
    • b) update num to 10;
    • c) set num = 10;
    • d) var num = 10;

Constants and Literals

  1. Which of the following declares a constant integer variable?
    • a) const int x = 5;
    • b) int const x = 5;
    • c) #define x 5
    • d) All of the above
  2. What keyword is used to create a constant variable in C?
    • a) constant
    • b) const
    • c) define
    • d) static
  3. Which of the following is a string literal?
    • a) ‘A’
    • b) “Hello”
    • c) 5
    • d) const
  4. What is a literal in C?
    • a) A variable name
    • b) A constant value
    • c) A data type
    • d) A function
  5. Which keyword is used for symbolic constants?
    • a) #const
    • b) #define
    • c) const
    • d) static
  6. Which of the following statements is correct for constants in C?
    • a) They can be modified at any time
    • b) Their values cannot be changed
    • c) They can be used only within functions
    • d) They are stored in the stack
  7. Which of the following is a valid integer literal?
    • a) “100”
    • b) 100
    • c) 100.0
    • d) 1e2
  8. What is the value of the literal 'A' in integer form?
    • a) 0
    • b) 65
    • c) ‘A’
    • d) Undefined
  9. How do you define a constant literal in C using the #define directive?
    • a) #define PI 3.14
    • b) #const PI 3.14
    • c) const PI = 3.14;
    • d) define PI = 3.14;
  10. What does const float PI = 3.14; do in C?
    • a) Declares a constant float variable
    • b) Declares a regular variable
    • c) Declares a variable that can be changed
    • d) Declares an integer constant

Keywords and Identifiers

  1. Which of the following is a keyword in C?
    • a) return
    • b) main
    • c) printf
    • d) int
  2. Which of the following is a valid identifier in C?
    • a) for
    • b) 2total
    • c) _value
    • d) class
  3. Keywords in C are:
    • a) User-defined words
    • b) Predefined reserved words
    • c) Synonyms for variables
    • d) Functions
  4. Which of the following is not a valid keyword in C?
    • a) auto
    • b) case
    • c) execute
    • d) volatile
  5. How many keywords are there in standard C?
    • a) 32
    • b) 28
    • c) 24
    • d) 30
  6. Identifiers are:
    • a) User-defined names
    • b) Reserved words
    • c) Only used for constants
    • d) Defined only for functions
  7. Which of the following is not an identifier?
    • a) variable1
    • b) #define
    • c) function_name
    • d) totalSum
  8. Which identifier is valid in C?
    • a) total@sum
    • b) _total_sum
    • c) 5value
    • d) int
  9. Which of these cannot be an identifier?
    • a) MyVariable
    • b) _temp
    • c) 123abc
    • d) var
  10. What does the keyword void mean?
    • a) No return type
    • b) Empty variable
    • c) Reserved variable
    • d) Zero integer

Type Conversion (Implicit and Explicit)

  1. What is implicit type conversion?
    • a) Automatic conversion of one data type to another
    • b) Manually converting one data type to another
    • c) Defining a new data type
    • d) All of the above
  2. Which function is used for explicit type conversion?
    • a) atoi()
    • b) typecast
    • c) cast
    • d) convert
  3. Which type conversion is handled by the compiler?
    • a) Explicit
    • b) Manual
    • c) Implicit
    • d) String
  4. What is explicit type conversion also known as?
    • a) Typecasting
    • b) Implicit conversion
    • c) Auto conversion
    • d) Dynamic typing
  5. What will the following code return? int a = (int) 3.14;
    • a) 3
    • b) 3.14
    • c) 4
    • d) 0
  6. Which of the following best describes type conversion?
    • a) It allows functions to use any data type
    • b) Changing one data type to another
    • c) A part of syntax error
    • d) A technique to declare constants
  7. Which of the following is an example of implicit type conversion?
    • a) int a = 5.0;
    • b) int a = (int)5.0;
    • c) double a = 3;
    • d) (float)a;
  8. What is the term for converting a higher data type to a lower one?
    • a) Narrowing conversion
    • b) Widening conversion
    • c) Implicit conversion
    • d) Non-conversion
  9. In C, which conversion will not happen automatically?
    • a) int to float
    • b) float to int
    • c) double to float
    • d) char to int
  10. What is the result of float f = (float)10 / 3; in C?
    • a) 3.3333
    • b) 3.0
    • c) 3.33
    • d) Error

Answer Key

Q1Q2Q3Q4Q5Q6Q7Q8Q9Q10
cbabccbbaa
Q11Q12Q13Q14Q15Q16Q17Q18Q19Q20
bbbbbabbca
Q21Q22Q23Q24Q25Q26Q27Q28Q29Q30
dbbbbbbbaa
Q31Q32Q33Q34Q35Q36Q37Q38Q39Q40
acbcaabbca
Q41Q42Q43Q44Q45Q46Q47Q48Q49Q50
aacaabcaba

Use a Blank Sheet, Note your Answers and Finally tally with our answer at last. Give Yourself Score.

X
error: Content is protected !!
Scroll to Top