C- Declarations and Initializations Questions and Answers

Practice Mode
Showing 10 of 49 questions
Q31
What is the size of an int data type in C?
  • A 2 bytes
  • B 4 bytes
  • C 8 bytes
  • D Depends on compiler
Answer: Option D
Explanation: Size of int is compiler dependent, typically 2 or 4 bytes.
Q32
Which keyword is used to define a constant in C?
  • A constant
  • B define
  • C const
  • D fixed
Answer: Option C
Explanation: const keyword is used to define read-only variables.
Q33
What is the default value of a static variable in C?
  • A 0
  • B 1
  • C Garbage value
  • D NULL
Answer: Option A
Explanation: Static variables are automatically initialized to zero.
Q34
Which of the following is a valid declaration?
  • A int arr[0];
  • B int arr[];
  • C int arr[5];
  • D int arr[-5];
Answer: Option C
Explanation: Array size must be positive integer constant.
Q35
What does the "volatile" keyword indicate?
  • A Variable cannot be changed
  • B Variable is optimized
  • C Variable may change unexpectedly
  • D Variable is constant
Answer: Option C
Explanation: Volatile tells compiler that variable may change unexpectedly.
Q36
Which storage class has the longest scope?
  • A auto
  • B register
  • C static
  • D extern
Answer: Option D
Explanation: Global variables exist throughout program execution.
Q37
What is the output of: printf("%d", sizeof('A'));
  • A 1
  • B 2
  • C 4
  • D 8
Answer: Option A
Explanation: Character constants are of type int in C.
Q38
Which is correct for declaring a pointer?
  • A int ptr*;
  • B int *ptr;
  • C *int ptr;
  • D int pointer;
Answer: Option B
Explanation: Asterisk is used to declare pointer variables.
Q39
What is the maximum length of a C identifier?
  • A 31 characters
  • B 63 characters
  • C 79 characters
  • D 255 characters
Answer: Option A
Explanation: C standard specifies 31 characters for internal identifiers.
Q40
Which is not a fundamental data type in C?
  • A int
  • B float
  • C char
  • D string
Answer: Option D
Explanation: String is not a fundamental type; it's array of characters.
Questions and Answers for Competitive Exams Various Entrance Test