1. What keyword is used to define a variable in C?
ⓐ. var
ⓑ. define
ⓒ. int
ⓓ. declare
Explanation: In C programming, the keyword “int” is used to declare integer variables. For example, “int x;” declares a variable named ‘x’ of type integer.
2. What is the size of the ‘char’ data type in C?
ⓐ. 1 byte
ⓑ. 2 bytes
ⓒ. 4 bytes
ⓓ. It varies depending on the system
Explanation: The ‘char’ data type in C is typically 1 byte in size. It is used to store characters and small integers within the ASCII range.
3. Which data type is used to store floating-point numbers in C?
ⓐ. float
ⓑ. double
ⓒ. real
ⓓ. decimal
Explanation: The ‘float’ data type in C is used to store single-precision floating-point numbers, which have a smaller range and precision compared to ‘double’.
4. What does the ‘sizeof’ operator return in C?
ⓐ. The value of the variable
ⓑ. The size of the variable in bytes
ⓒ. The address of the variable
ⓓ. The type of the variable
Explanation: The ‘sizeof’ operator in C returns the size of a variable or data type in bytes. For example, ‘sizeof(int)’ returns the size of an integer in bytes.
5. Which symbol is used for the modulus operator in C?
ⓐ. %
ⓑ. /
ⓒ.
ⓓ. &#
Explanation: The modulus operator in C is represented by the ‘%’ symbol. It returns the remainder of a division operation.
6. What is the default value of an uninitialized variable in C?
ⓐ. 0
ⓑ. 1
ⓒ. Garbage value
ⓓ. Undefined
Explanation: In C programming, the default value of an uninitialized variable is a garbage value, which is the value stored at its memory location before it is explicitly assigned a value.
7. Which data type is used to store true or false values in C?
ⓐ. bool
ⓑ. boolean
ⓒ. truefalse
ⓓ. tf
Explanation: In C99 and later versions, the ‘bool’ data type is used to store true or false values, with ‘true’ represented by non-zero and ‘false’ represented by zero.
8. What is the maximum value that can be stored in an ‘int’ variable in C?
ⓐ. 127
ⓑ. 255
ⓒ. 32,767
ⓓ. It depends on the system
Explanation: The maximum value that can be stored in an ‘int’ variable in C depends on the system architecture. It can vary between different systems.
9. Which escape sequence is used to represent a new line character in C?
ⓐ. \n
ⓑ. \r
ⓒ. \t
ⓓ. \b
Explanation: The escape sequence ‘\n’ is used to represent a new line character in C. It moves the cursor to the beginning of the next line.
10. Which data type is used to store memory addresses in C?
ⓐ. pointer
ⓑ. addr
ⓒ. address
ⓓ. memaddr
Explanation: In C programming, the ‘pointer’ data type is used to store memory addresses. It holds the address of a variable or a memory location in the computer’s memory.
11. Which data type is used to store single-precision floating-point numbers in C?
ⓐ. float
ⓑ. double
ⓒ. long
ⓓ. short
Explanation: Single-precision floating-point numbers are stored using the ‘float’ data type in C, which typically occupies 4 bytes of memory.
12. What is the size of the ‘int’ data type in C on most modern systems?
ⓐ. 2 bytes
ⓑ. 4 bytes
ⓒ. 8 bytes
ⓓ. It varies depending on the system
Explanation: On most modern systems, the ‘int’ data type in C occupies 4 bytes of memory, allowing it to represent integer values within a certain range.
13. Which data type is used to store single characters in C?
ⓐ. char
ⓑ. string
ⓒ. character
ⓓ. letter
Explanation: The ‘char’ data type in C is used to store single characters, such as letters, digits, and special symbols. It typically occupies 1 byte of memory.
14. What is the range of values that can be stored in a ‘char’ variable in C?
ⓐ. -128 to 127
ⓑ. 0 to 255
ⓒ. -32768 to 32767
ⓓ. It varies depending on the system
Explanation: The range of values that can be stored in a ‘char’ variable in C can vary depending on the system architecture. It may be signed or unsigned, affecting the range of representable values.
15. Which data type is used to store double-precision floating-point numbers in C?
ⓐ. double
ⓑ. float
ⓒ. long double
ⓓ. real
Explanation: Double-precision floating-point numbers are stored using the ‘double’ data type in C, which typically occupies 8 bytes of memory, providing increased precision compared to ‘float’.
16. What is the default size of ‘float’ data type in C?
ⓐ. 2 bytes
ⓑ. 4 bytes
ⓒ. 8 bytes
ⓓ. It varies depending on the system
Explanation: The default size of the ‘float’ data type in C is typically 4 bytes on most systems, allowing it to store single-precision floating-point numbers.
17. Which data type is used to store large floating-point numbers with increased precision in C?
ⓐ. float
ⓑ. double
ⓒ. long double
ⓓ. real
Explanation: The ‘long double’ data type in C is used to store large floating-point numbers with increased precision compared to ‘float’ and ‘double’. It typically occupies more memory than ‘double’.
18. What is the maximum value that can be stored in a ‘char’ variable in C?
ⓐ. 127
ⓑ. 255
ⓒ. 32767
ⓓ. It varies depending on the system
Explanation: The maximum value that can be stored in a ‘char’ variable in C depends on whether it is signed or unsigned, which varies depending on the system architecture.
19. Which data type is used to store very large integer values in C?
ⓐ. int
ⓑ. long
ⓒ. short
ⓓ. double
Explanation: The ‘long’ data type in C is used to store very large integer values, providing a wider range compared to the ‘int’ data type.
20. What is the size of the ‘double’ data type in C?
ⓐ. 4 bytes
ⓑ. 8 bytes
ⓒ. 16 bytes
ⓓ. It varies depending on the system
Explanation: The ‘double’ data type in C typically occupies 8 bytes of memory on most systems, allowing it to store double-precision floating-point numbers.
21. Which data type is used to store integers with a larger range compared to ‘int’ in C?
ⓐ. short
ⓑ. long
ⓒ. long int
ⓓ. unsigned int
Explanation: The ‘long’ data type in C is used to store integers with a larger range compared to ‘int’. It typically occupies 4 or 8 bytes of memory, depending on the system.
22. What is the keyword used to declare a variable as constant in C?
ⓐ. var
ⓑ. const
ⓒ. constant
ⓓ. readonly
Explanation: The ‘const’ keyword in C is used to declare a variable as constant, meaning its value cannot be changed once it is initialized.
23. Which data type is used to store boolean values in C?
ⓐ. bool
ⓑ. boolean
ⓒ. int
ⓓ. char
Explanation: In C, boolean values are often represented using the ‘int’ data type, where ‘0’ represents false and any non-zero value represents true.
24. What is the maximum value that can be stored in an ‘unsigned int’ variable in C?
ⓐ. 32767
ⓑ. 65535
ⓒ. 2147483647
ⓓ. It depends on the system
Explanation: The maximum value that can be stored in an ‘unsigned int’ variable in C is 65535, as it can store only non-negative integers.
25. Which data type is used to store large integers with increased precision in C?
ⓐ. int
ⓑ. long
ⓒ. long long
ⓓ. double
Explanation: The ‘long long’ data type in C is used to store large integers with increased precision, providing a wider range compared to ‘int’ and ‘long’.
26. What is the size of the ‘long double’ data type in C on most systems?
ⓐ. 4 bytes
ⓑ. 8 bytes
ⓒ. 12 bytes
ⓓ. It varies depending on the system
Explanation: The size of the ‘long double’ data type in C can vary depending on the system architecture and compiler implementation, typically ranging from 8 to 16 bytes.
27. Which data type is used to represent the absence of a value in C?
ⓐ. void
ⓑ. null
ⓒ. None
ⓓ. empty
Explanation: The ‘void’ data type in C is used to represent the absence of a value. It is commonly used for functions that do not return a value or pointers that do not point to any data type.
28. What is the default value of an uninitialized global variable in C?
ⓐ. 0
ⓑ. 1
ⓒ. Garbage value
ⓓ. Undefined
Explanation: Global variables in C are automatically initialized to zero if no initial value is specified, unlike local variables which contain garbage values if left uninitialized.
29. Which data type is used to store characters with a wider range compared to ‘char’ in C?
ⓐ. wchar_t
ⓑ. widechar
ⓒ. wchar
ⓓ. widechar_t
Explanation: The ‘wchar_t’ data type in C is used to store wide characters, providing a wider range compared to the standard ‘char’ data type.
30. What is the size of the ‘wchar_t’ data type in C on most systems?
ⓐ. 1 byte
ⓑ. 2 bytes
ⓒ. 4 bytes
ⓓ. It varies depending on the system
Explanation: The size of the ‘wchar_t’ data type in C can vary depending on the system architecture and compiler implementation, typically ranging from 2 to 4 bytes.
31. Which data type is used to store a single Unicode character in C?
ⓐ. char
ⓑ. wchar_t
ⓒ. unicode
ⓓ. wchar
Explanation: The ‘wchar_t’ data type in C is commonly used to store a single Unicode character, which can represent characters from various language scripts.
32. What is the size of the ‘wchar_t’ data type in C on most systems?
ⓐ. 1 byte
ⓑ. 2 bytes
ⓒ. 4 bytes
ⓓ. It varies depending on the system
Explanation: The size of the ‘wchar_t’ data type in C can vary depending on the system architecture and compiler implementation, typically ranging from 2 to 4 bytes.
33. Which data type is used to store a single byte of data in C?
ⓐ. byte
ⓑ. char
ⓒ. short
ⓓ. int
Explanation: In C programming, the ‘char’ data type is commonly used to store a single byte of data, which can represent characters or small integers.
34. What is the size of the ‘short’ data type in C?
ⓐ. 1 byte
ⓑ. 2 bytes
ⓒ. 4 bytes
ⓓ. It varies depending on the system
Explanation: The ‘short’ data type in C typically occupies 2 bytes of memory on most systems, allowing it to store integer values within a certain range.
35. Which data type is used to store very large integer values with increased precision in C?
ⓐ. long
ⓑ. long int
ⓒ. long long
ⓓ. double
Explanation: The ‘long long’ data type in C is used to store very large integer values with increased precision compared to ‘int’ and ‘long’.
36. What is the maximum value that can be stored in a ‘long’ variable in C?
ⓐ. 32767
ⓑ. 2147483647
ⓒ. 9223372036854775807
ⓓ. It depends on the system
Explanation: The maximum value that can be stored in a ‘long’ variable in C depends on the system architecture, as it can vary between systems.
37. Which data type is used to store single-precision floating-point numbers with increased precision in C?
ⓐ. long float
ⓑ. long double
ⓒ. extended
ⓓ. real
Explanation: The ‘long double’ data type in C is used to store single-precision floating-point numbers with increased precision compared to ‘float’.
38. What is the keyword used to declare a variable as a pointer in C?
ⓐ. ptr
ⓑ. point
ⓒ. pointer
ⓓ. *
Explanation: The ‘*’ symbol in C is used to declare a variable as a pointer, indicating that it stores the memory address of another variable.
39. Which data type is used to store boolean values in C99 and later versions?
ⓐ. bool
ⓑ. boolean
ⓒ. int
ⓓ. char
Explanation: In C99 and later versions, the ‘bool’ data type is used to store boolean values, where ‘true’ is represented by non-zero and ‘false’ by zero.
40. What is the default value of an uninitialized local variable in C?
ⓐ. 0
ⓑ. 1
ⓒ. Garbage value
ⓓ. Undefined
Explanation: Uninitialized local variables in C contain garbage values, which are the values stored at their memory locations before they are explicitly assigned a value.
41. Which keyword is used to declare a variable as unsigned in C?
ⓐ. signed
ⓑ. unsigned
ⓒ. unsgn
ⓓ. us
Explanation: The ‘unsigned’ keyword in C is used to declare a variable as unsigned, meaning it can only store non-negative integer values.
42. What is the range of values that can be stored in an ‘unsigned char’ variable in C?
ⓐ. 0 to 127
ⓑ. 0 to 255
ⓒ. -128 to 127
ⓓ. It varies depending on the system
Explanation: The range of values that can be stored in an ‘unsigned char’ variable in C is from 0 to 255, as it can only store non-negative integers.
43. Which data type modifier is used to increase the range of values that can be stored in an integer variable in C?
ⓐ. signed
ⓑ. unsigned
ⓒ. short
ⓓ. long
Explanation: The ‘long’ modifier in C is used to increase the range of values that can be stored in an integer variable, allowing it to represent larger integers.
44. What is the size of the ‘long int’ data type in C on most systems?
ⓐ. 2 bytes
ⓑ. 4 bytes
ⓒ. 8 bytes
ⓓ. It varies depending on the system
Explanation: The ‘long int’ data type in C typically occupies 4 bytes of memory on most systems, allowing it to store larger integer values.
45. Which data type modifier is used to decrease the range of values that can be stored in an integer variable in C?
ⓐ. signed
ⓑ. unsigned
ⓒ. short
ⓓ. long
Explanation: The ‘short’ modifier in C is used to decrease the range of values that can be stored in an integer variable, allowing it to represent smaller integers.
46. What is the range of values that can be stored in a ‘short int’ variable in C?
ⓐ. -32768 to 32767
ⓑ. 0 to 65535
ⓒ. 0 to 127
ⓓ. It varies depending on the system
Explanation: The range of values that can be stored in a ‘short int’ variable in C is from -32768 to 32767, as it is typically a signed 16-bit integer.
47. Which data type modifier is used to explicitly specify the size of an integer variable in C?
ⓐ. short
ⓑ. long
ⓒ. int
ⓓ. sizeof
Explanation: In C, the ‘int’ keyword itself can be used to declare integer variables without explicitly specifying their size, relying on the compiler to determine an appropriate size.
48. What is the size of the ‘unsigned long int’ data type in C on most systems?
ⓐ. 4 bytes
ⓑ. 8 bytes
ⓒ. 16 bytes
ⓓ. It varies depending on the system
Explanation: The ‘unsigned long int’ data type in C typically occupies 8 bytes of memory on most systems, allowing it to store larger non-negative integer values.
49. Which data type modifier is used to explicitly specify the size of a floating-point variable in C?
ⓐ. short
ⓑ. long
ⓒ. float
ⓓ. double
Explanation: In C, the ‘double’ data type is used to declare floating-point variables without explicitly specifying their size, as it typically provides more precision than ‘float’.
50. What is the range of values that can be stored in a ‘long long int’ variable in C?
ⓐ. -9223372036854775808 to 9223372036854775807
ⓑ. -2147483648 to 2147483647
ⓒ. 0 to 18446744073709551615
ⓓ. It varies depending on the system
Explanation: The range of values that can be stored in a ‘long long int’ variable in C is from -9223372036854775808 to 9223372036854775807, as it is typically a signed 64-bit integer.
51. Which data type modifier is used to declare an integer variable as both ‘long’ and ‘unsigned’ in C?
ⓐ. long
ⓑ. unsigned
ⓒ. long unsigned
ⓓ. long int unsigned
Explanation: The ‘long unsigned’ modifier in C is used to declare an integer variable as both ‘long’ and ‘unsigned’, allowing it to store large non-negative integer values.
52. What is the size of the ‘long double’ data type in C on most systems?
ⓐ. 4 bytes
ⓑ. 8 bytes
ⓒ. 12 bytes
ⓓ. It varies depending on the system
Explanation: The size of the ‘long double’ data type in C can vary depending on the system architecture and compiler implementation, typically ranging from 8 to 16 bytes.
53. Which data type modifier is used to declare a floating-point variable with increased precision in C?
ⓐ. short
ⓑ. long
ⓒ. double
ⓓ. extended
Explanation: The ‘double’ modifier in C is used to declare a floating-point variable with increased precision compared to ‘float’, typically occupying 8 bytes of memory on most systems.
54. What is the range of values that can be stored in a ‘long double’ variable in C?
ⓐ. -3.4E38 to 3.4E38
ⓑ. -1.7E308 to 1.7E308
ⓒ. -9223372036854775808 to 9223372036854775807
ⓓ. It varies depending on the system
Explanation: The range of values that can be stored in a ‘long double’ variable in C can vary depending on the system architecture and compiler implementation, typically providing increased precision compared to ‘double’.
55. Which data type modifier is used to declare an integer variable with increased range in C?
ⓐ. long
ⓑ. short
ⓒ. long long
ⓓ. unsigned
Explanation: The ‘long long’ modifier in C is used to declare an integer variable with increased range compared to ‘int’, typically allowing it to store larger integer values.
56. What is the size of the ‘short int’ data type in C on most systems?
ⓐ. 2 bytes
ⓑ. 4 bytes
ⓒ. 8 bytes
ⓓ. It varies depending on the system
Explanation: The ‘short int’ data type in C typically occupies 2 bytes of memory on most systems, providing a smaller range compared to ‘int’.
57. Which data type modifier is used to declare a floating-point variable with increased precision in C?
ⓐ. long
ⓑ. short
ⓒ. long double
ⓓ. long float
Explanation: The ‘long double’ modifier in C is used to declare a floating-point variable with increased precision compared to ‘float’ and ‘double’.
58. What is the range of values that can be stored in an ‘unsigned long int’ variable in C?
ⓐ. 0 to 2147483647
ⓑ. 0 to 4294967295
ⓒ. -2147483648 to 2147483647
ⓓ. It varies depending on the system
Explanation: The range of values that can be stored in an ‘unsigned long int’ variable in C is from 0 to 4294967295, as it can only store non-negative integers.
59. Which data type modifier is used to declare an integer variable with increased range and size in C?
ⓐ. long
ⓑ. short
ⓒ. long int
ⓓ. long long
Explanation: The ‘long long’ modifier in C is used to declare an integer variable with increased range and size compared to ‘int’ and ‘long’, typically allowing it to store larger integer values.
60. What is the size of the ‘unsigned long long int’ data type in C on most systems?
ⓐ. 4 bytes
ⓑ. 8 bytes
ⓒ. 16 bytes
ⓓ. It varies depending on the system
Explanation: The ‘unsigned long long int’ data type in C typically occupies 8 bytes of memory on most systems, allowing it to store larger non-negative integer values.
61. Which of the following is the correct way to declare a variable named ‘x’ of type integer in C?
ⓐ. integer x;
ⓑ. x integer;
ⓒ. int x;
ⓓ. declare x as integer;
Explanation: In C, the correct syntax to declare a variable named ‘x’ of type integer is ‘int x;’.
62. What is the purpose of variable initialization in C?
ⓐ. To declare a variable
ⓑ. To allocate memory for a variable
ⓒ. To assign an initial value to a variable
ⓓ. To free memory used by a variable
Explanation: Variable initialization in C involves assigning an initial value to a variable at the time of declaration.
63. Which of the following is the correct way to initialize a variable named ‘count’ of type integer to 0 in C?
ⓐ. int count = 0;
ⓑ. count = 0;
ⓒ. initialize count to 0;
ⓓ. set count as 0;
Explanation: In C, the correct way to initialize a variable named ‘count’ of type integer to 0 is ‘int count = 0;’.
64. What happens if a variable is used without being initialized in C?
ⓐ. The program will not compile
ⓑ. The variable will be automatically initialized to 0
ⓒ. The variable will contain garbage value
ⓓ. The program will throw a runtime error
Explanation: If a variable is used without being initialized in C, it will contain a garbage value, which is the value stored at its memory location before it is explicitly assigned a value.
65. Which of the following is the correct way to declare multiple variables of the same type in C?
ⓐ. int a, b, c;
ⓑ. int a; int b; int c;
ⓒ. declare a, b, c as int;
ⓓ. a, b, c int;
Explanation: In C, multiple variables of the same type can be declared in a single line by separating their names with commas.
66. What is the scope of a variable in C?
ⓐ. The memory allocated to the variable
ⓑ. The range of values that the variable can store
ⓒ. The part of the program where the variable is accessible
ⓓ. The lifetime of the variable
Explanation: The scope of a variable in C refers to the part of the program where the variable can be accessed and used.
67. Which of the following is the correct syntax to declare a constant named ‘PI’ with a value of 3.14 in C?
ⓐ. const PI = 3.14;
ⓑ. const float PI = 3.14;
ⓒ. #define PI 3.14
ⓓ. define PI as 3.14
Explanation: In C, the correct syntax to declare a constant named ‘PI’ with a value of 3.14 is ‘const float PI = 3.14;’.
68. What is the purpose of declaring a variable as constant in C?
ⓐ. To prevent the variable from being initialized
ⓑ. To allocate memory for the variable
ⓒ. To indicate that the variable’s value cannot be changed
ⓓ. To free memory used by the variable
Explanation: Declaring a variable as constant in C using the ‘const’ keyword indicates that the variable’s value cannot be changed once it is initialized.
69. Which of the following is the correct way to declare a global variable in C?
ⓐ. global int x;
ⓑ. int x global;
ⓒ. extern int x;
ⓓ. int x;
Explanation: In C, global variables are declared outside of any function, typically at the beginning of the file, without using the ‘extern’ keyword.
70. What is the significance of variable declaration in C?
ⓐ. It allocates memory for the variable
ⓑ. It assigns an initial value to the variable
ⓒ. It indicates the type and name of the variable
ⓓ. It frees memory used by the variable
Explanation: Variable declaration in C indicates the type and name of the variable, allowing the compiler to allocate memory and perform type checking during compilation.
71. What is the lifetime of a local variable in C?
ⓐ. Until the program terminates
ⓑ. Until the function in which it is declared returns
ⓒ. Until the next function call
ⓓ. Until the next program execution
Explanation: Local variables in C have a lifetime limited to the duration of the function in which they are declared. They are destroyed once the function exits.
72. Which of the following statements about global variables in C is true?
ⓐ. Global variables have a limited scope within the function where they are declared.
ⓑ. Global variables can only be accessed within the file where they are declared.
ⓒ. Global variables have a longer lifetime compared to local variables.
ⓓ. Global variables cannot be modified after initialization.
Explanation: Global variables in C have a longer lifetime compared to local variables. They exist throughout the entire execution of the program.
73. What is the scope of a global variable in C?
ⓐ. The entire program
ⓑ. The function where it is declared
ⓒ. The block where it is declared
ⓓ. The file where it is declared
Explanation: Global variables in C have a scope that extends throughout the entire program, allowing them to be accessed from any part of the code.
74. Which of the following statements about static variables in C is true?
ⓐ. Static variables can be initialized multiple times.
ⓑ. Static variables have a shorter lifetime compared to automatic variables.
ⓒ. Static variables retain their value between function calls.
ⓓ. Static variables cannot be accessed from outside the file where they are declared.
Explanation: Static variables in C retain their value between function calls, unlike automatic variables whose value is lost once the function exits.
75. What is the scope of a static variable in C?
ⓐ. The entire program
ⓑ. The function where it is declared
ⓒ. The block where it is declared
ⓓ. The file where it is declared
Explanation: The scope of a static variable in C is limited to the function where it is declared, but its lifetime extends beyond the function call.
76. Which of the following statements about local variables in C is true?
ⓐ. Local variables have a longer lifetime compared to global variables.
ⓑ. Local variables cannot be accessed from outside the function where they are declared.
ⓒ. Local variables retain their value between function calls.
ⓓ. Local variables are initialized to zero by default.
Explanation: Local variables in C have a limited scope and cannot be accessed from outside the function where they are declared.
77. Which keyword is used to declare a variable with file scope in C?
ⓐ. static
ⓑ. local
ⓒ. global
ⓓ. extern
Explanation: The ‘extern’ keyword in C is used to declare a variable with file scope, allowing it to be accessed from other files.
78. What is the lifetime of a static variable in C?
ⓐ. Until the program terminates
ⓑ. Until the function in which it is declared returns
ⓒ. Until the next function call
ⓓ. Until the next program execution
Explanation: Static variables in C have a lifetime that extends throughout the entire execution of the program, unlike local variables whose lifetime is limited to the function scope.
79. Which of the following statements about variable scope in C is true?
ⓐ. Local variables can be accessed from outside the function where they are declared.
ⓑ. Global variables have a shorter lifetime compared to static variables.
ⓒ. Static variables have a limited scope within the function where they are declared.
ⓓ. File-scope variables can only be accessed within the file where they are declared.
Explanation: File-scope variables in C, whether they are global or static, can only be accessed within the file where they are declared.
80. What is the purpose of using the ‘const’ keyword in C?
ⓐ. To declare a variable as constant
ⓑ. To allocate memory for a variable
ⓒ. To indicate the variable’s type
ⓓ. To free memory used by a variable
Explanation: The ‘const’ keyword in C is used to declare a variable as constant, meaning its value cannot be changed after initialization.
81. Which of the following statements about constants in C is true?
ⓐ. Constants can be modified after initialization.
ⓑ. Constants must be initialized at the time of declaration.
ⓒ. Constants can only be of integer type.
ⓓ. Constants have a shorter lifetime compared to variables.
Explanation: In C, constants must be initialized at the time of declaration and cannot be modified thereafter.
82. What is the syntax to declare a constant integer named ‘MAX_VALUE’ with a value of 100 in C?
ⓐ. const MAX_VALUE = 100;
ⓑ. const int MAX_VALUE = 100;
ⓒ. define MAX_VALUE as 100
ⓓ. const MAX_VALUE : 100;
Explanation: In C, the correct syntax to declare a constant integer named ‘MAX_VALUE’ with a value of 100 is ‘const int MAX_VALUE = 100;’.
83. Which of the following is a valid way to use a constant in C?
ⓐ. Changing its value after initialization
ⓑ. Assigning a value to it using a scanf function
ⓒ. Using it to define the size of an array
ⓓ. Declaring it without initializing it
Explanation: Constants in C are often used to define the size of arrays and other fixed values that do not change during program execution.
84. What is the benefit of using constants in C?
ⓐ. They reduce the amount of memory used by the program.
ⓑ. They improve the performance of the program.
ⓒ. They make the code easier to understand and maintain.
ⓓ. They allow variables to be modified dynamically.
Explanation: Constants in C make the code easier to understand and maintain by providing meaningful names to fixed values used throughout the program.
85. Which of the following statements about constants in C is false?
ⓐ. Constants cannot be modified after initialization.
ⓑ. Constants must be initialized at the time of declaration.
ⓒ. Constants can only be of integer type.
ⓓ. Constants are declared using the ‘const’ keyword.
Explanation: Constants in C can be of various types, including integers, floating-point numbers, characters, and pointers.
86. What is the difference between a constant and a variable in C?
ⓐ. Constants cannot be initialized.
ⓑ. Variables can be modified after initialization, while constants cannot.
ⓒ. Variables have a longer lifetime compared to constants.
ⓓ. Constants are stored in read-only memory, while variables are stored in stack memory.
Explanation: In C, variables can have their values changed after initialization, while constants cannot be modified once they are initialized.
87. What happens if you try to modify a constant variable in C?
ⓐ. The program will not compile.
ⓑ. The compiler will generate a warning.
ⓒ. The program will throw a runtime error.
ⓓ. The modification will be allowed, but with a warning message.
Explanation: In C, attempting to modify a constant variable results in a compilation error, as constants are meant to be immutable.
88. What is the significance of using constants in function prototypes in C?
ⓐ. It indicates that the function does not return a value.
ⓑ. It indicates that the function parameters cannot be modified.
ⓒ. It improves code readability by providing meaningful names to parameters.
ⓓ. It ensures type consistency between function calls and definitions.
Explanation: Using constants in function prototypes in C ensures type consistency between function calls and their definitions, helping prevent errors related to incorrect parameter types.
89. What is the purpose of the ‘volatile’ keyword in C?
ⓐ. To declare a variable as constant
ⓑ. To allocate memory for a variable
ⓒ. To indicate that the variable’s value can be changed by external factors
ⓓ. To indicate the variable’s type
Explanation: The ‘volatile’ keyword in C is used to indicate that the value of a variable can be changed unexpectedly by external factors such as hardware interrupts or concurrently executing threads.
90. Which of the following statements about volatile variables in C is true?
ⓐ. Volatile variables are automatically initialized to zero.
ⓑ. Volatile variables cannot be modified after initialization.
ⓒ. Volatile variables are optimized by the compiler for better performance.
ⓓ. Volatile variables should be used for variables whose values never change.
Explanation: Volatile variables in C are not optimized by the compiler for performance improvements, as their values can change unexpectedly due to external factors.
91. What is the difference between using ‘const’ and ‘volatile’ keywords in C?
ⓐ. ‘const’ indicates that the variable’s value can change, while ‘volatile’ indicates that it cannot.
ⓑ. ‘const’ indicates that the variable is stored in read-only memory, while ‘volatile’ indicates that it is stored in volatile memory.
ⓒ. ‘const’ indicates that the variable’s value cannot change unexpectedly, while ‘volatile’ indicates that it can.
ⓓ. ‘const’ and ‘volatile’ are used interchangeably in C.
Explanation: The ‘const’ keyword in C indicates that a variable’s value cannot change after initialization, while the ‘volatile’ keyword indicates that its value can change unexpectedly due to external factors.
92. Which of the following situations is a suitable use case for the ‘volatile’ keyword in C?
ⓐ. Storing constant values used throughout the program.
ⓑ. Storing variables that are modified frequently within a loop.
ⓒ. Storing variables that are never modified after initialization.
ⓓ. Storing variables whose values are computed based on user input.
Explanation: The ‘volatile’ keyword in C is suitable for variables whose values can change unexpectedly, such as those computed based on user input or modified by hardware interrupts.
93. What happens if you omit the ‘volatile’ keyword for variables that are accessed by multiple threads or hardware interrupts in C?
ⓐ. The compiler generates a warning.
ⓑ. The program crashes at runtime.
ⓒ. The compiler may optimize the code incorrectly, leading to unexpected behavior.
ⓓ. The program runs slower due to unnecessary optimizations.
Explanation: Omitting the ‘volatile’ keyword for variables accessed by multiple threads or hardware interrupts in C may lead to incorrect optimizations by the compiler, resulting in unexpected behavior.
94. In which scenario is using the ‘volatile’ keyword unnecessary in C?
ⓐ. When dealing with variables that are accessed only by a single thread.
ⓑ. When dealing with variables that are modified frequently within a loop.
ⓒ. When dealing with variables that represent constant values.
ⓓ. When dealing with variables that are used as function parameters.
Explanation: Using the ‘volatile’ keyword is unnecessary in C when dealing with variables that are accessed only by a single thread, as there are no external factors that can change their values unexpectedly.
95. What is the effect of using the ‘volatile’ keyword on the optimization performed by the compiler in C?
ⓐ. It prevents all optimizations by the compiler.
ⓑ. It enables aggressive optimizations by the compiler.
ⓒ. It limits optimizations that could lead to incorrect behavior.
ⓓ. It has no effect on compiler optimizations.
Explanation: The ‘volatile’ keyword in C limits certain optimizations by the compiler that could lead to incorrect behavior, ensuring that the variable’s value is always read from memory rather than cached registers.
96. Which of the following statements about volatile variables in C is false?
ⓐ. Volatile variables should be used for variables accessed by multiple threads or hardware interrupts.
ⓑ. The value of a volatile variable can change unexpectedly due to external factors.
ⓒ. Volatile variables are optimized by the compiler for better performance.
ⓓ. Omitting the ‘volatile’ keyword for variables accessed by multiple threads or hardware interrupts may lead to incorrect behavior.
Explanation: Volatile variables in C are not optimized by the compiler for better performance, as their values can change unexpectedly due to external factors.
97. What is the value of the integer variable?
int main() {
int integerVariable = 10;
printf("Integer Variable: %d\n", integerVariable);
return 0;
}
ⓐ. 10
ⓑ. 3.14
ⓒ. ‘A’
ⓓ. 6.022e23
Explanation: The variable `integerVariable` is initialized to 10 using the assignment operator ‘=’.
98. What is the data type of the variable storing the character ‘A’?
int main() {
char characterVariable = 'A';
printf("Character Variable: %c\n", characterVariable);
return 0;
}
ⓐ. int
ⓑ. char
ⓒ. float
ⓓ. double
Explanation: The variable `characterVariable` is of type ‘char’ as it stores a single character.
99. What is the value of the double variable in scientific notation?
int main() {
double doubleVariable = 6.022e23;
printf("Double Variable: %e\n", doubleVariable);
return 0;
}
ⓐ. 10
ⓑ. 3.14
ⓒ. ‘A’
ⓓ. 6.022e23
Explanation: The variable `doubleVariable` is initialized to 6.022e23, representing a large number in scientific notation.
100. What is the value of ‘a’?
int main() {
int a = 5;
printf("Value of 'a': %d\n", a);
return 0;
}
ⓐ. 5
ⓑ. 7
ⓒ. 12
ⓓ. Undefined
Explanation: The variable ‘a’ is assigned the value 5.
101. What is the value of ‘sum’?
int main() {
int a = 5, b = 7;
int sum;
sum = a + b;
printf("Sum of %d and %d is: %d\n", a, b, sum);
return 0;
}
ⓐ. 5
ⓑ. 7
ⓒ. 12
ⓓ. Undefined
Explanation: The sum of ‘a’ and ‘b’ is assigned to ‘sum’, resulting in 12.
102. What is the value of the constant ‘AGE’?
int main() {
const int AGE = 30;
printf("Age: %d\n", AGE);
return 0;
}
ⓐ. 3.14159
ⓑ. 30
ⓒ. 5.0
ⓓ. Undefined
Explanation: The constant variable `AGE` is initialized to 30 and cannot be modified.
103. What is the value of ‘area’?
#define PI 3.14159
int main() {
const float RADIUS = 5.0;
float area = PI * RADIUS * RADIUS;
printf("Area of Circle: %.2f\n", area);
return 0;
}
ⓐ. 3.14159
ⓑ. 30
ⓒ. 5.0
ⓓ. Depends on the value of ‘PI’
Explanation: The variable ‘area’ is calculated using the constant ‘PI’ and ‘RADIUS’.
104. Where is the global variable declared?
int globalVariable = 10;
void func() {
printf("Global Variable: %d\n", globalVariable);
}
int main() {
func();
printf("Global Variable from main: %d\n", globalVariable);
return 0;
}
ⓐ. Inside the ‘func()’ function
ⓑ. Outside of any function
ⓒ. Inside the ‘main()’ function
ⓓ. Inside the ‘if’ statement in ‘main()’
Explanation: The global variable `globalVariable` is declared outside of any function, making it accessible globally.
105. What is the value of ‘localVariable’ in ‘func()’?
void func() {
int localVariable = 20;
printf("Local Variable: %d\n", localVariable);
}
int main() {
func();
return 0;
}
ⓐ. 10
ⓑ. 20
ⓒ. Undefined
ⓓ. Depends on the value of ‘globalVariable’
Explanation: The variable ‘localVariable’ is initialized to 20 inside the function ‘func()’, making its value 20 within the scope of the function.
106. What would happen if you attempt to access ‘localVariable’ inside the ‘main()’ function?
int main() {
printf("Global Variable from main: %d\n", globalVariable);
return 0;
}
ⓐ. It will print the value of ‘localVariable’.
ⓑ. It will print the value of ‘globalVariable’.
ⓒ. It will result in a compilation error.
ⓓ. It will print a garbage value.
Explanation: ‘localVariable’ is not accessible outside the ‘func()’ function, so attempting to access it in ‘main()’ will result in a compilation error.
107. What would happen if you declare a variable named ‘globalVariable’ inside the ‘main()’ function?
int main() {
int globalVariable = 10;
printf("Global Variable from main: %d\n", globalVariable);
return 0;
}
ⓐ. It will print the value of the global variable.
ⓑ. It will print the value of the local variable.
ⓒ. It will result in a compilation error.
ⓓ. It will print a garbage value.
Explanation: When a local variable shares the same name as a global variable, the local variable takes precedence inside its scope.
108. What is the value of ‘a’ inside the inner block?
int main() {
int a = 5;
{
int a = 10;
printf("Inner 'a': %d\n", a);
}
printf("Outer 'a': %d\n", a);
return 0;
}
ⓐ. 5
ⓑ. 10
ⓒ. Compilation Error
ⓓ. Undefined
Explanation: The inner block has its own scope, so the inner ‘a’ variable with the value 10 exists only within that block.
109. What would happen if you uncomment the line trying to print ‘y’ outside the if block?
int main() {
int x = 5;
if (x == 5) {
int y = 10;
printf("'y' inside if block: %d\n", y);
}
// printf("'y' outside if block: %d\n", y); // Uncommenting this line would result in a compilation error
return 0;
}
ⓐ. It will print the value of ‘y’.
ⓑ. It will print the value of ‘x’.
ⓒ. It will result in a compilation error.
ⓓ. It will print a garbage value.
Explanation: Variables declared within an if block are not accessible outside of it.
110. What would happen if you try to assign a new value to the constant variable ‘a’?
int main() {
const int a = 5;
a = 10;
printf("Value of 'a': %d\n", a);
return 0;
}
ⓐ. It will print the new value of ‘a’.
ⓑ. It will print the initial value of ‘a’.
ⓒ. It will result in a compilation error.
ⓓ. It will print a garbage value.
Explanation: Constants cannot be modified once they are assigned a value. Any attempt to modify them will result in a compilation error.