1. Which of the following is not a basic data type in C?
Answer:
Explanation:
In C, 'string' is not a basic data type. Strings are typically represented as arrays of characters.
2. What is the size of 'int' on a standard 32-bit system in C?
Answer:
Explanation:
On a standard 32-bit system, 'int' usually occupies 4 bytes.
3. Which data type would you use to store a character in C?
Answer:
Explanation:
The 'char' data type is used to store a single character in C.
4. What is the range of values for an unsigned char data type in C?
Answer:
Explanation:
An unsigned char has a range of 0 to 255, as it does not store negative values.
5. How is a floating-point number declared in C?
Answer:
Explanation:
Floating-point numbers in C can be declared using 'float', 'double', or 'long double', depending on the required precision.
6. What is the size of a 'double' data type in C on a typical 64-bit system?
Answer:
Explanation:
On a typical 64-bit system, the size of a 'double' is 8 bytes, but it can vary depending on the compiler and system architecture.
7. Which of the following data types is most suitable for storing a large integer, such as 10000000000, in C?
Answer:
Explanation:
The 'long' data type is suitable for storing larger integers. 'int' and 'unsigned int' may not be able to store such large values.
8. Which data type would be best to use for a variable that stores values -1, 0, and 1 in C?
Answer:
Explanation:
The 'int' data type is suitable for storing these values, as it can hold both negative and positive integers.
9. What is the size of the 'long long int' data type in C on most systems?
Answer:
Explanation:
On most systems, 'long long int' is 8 bytes, but this can vary with different system architectures.
10. In C, which of the following data types has the highest precision for storing decimal numbers?
Answer:
Explanation:
'long double' has the highest precision among floating-point data types in C.
11. Which keyword is used to define a boolean data type in C?
Answer:
Explanation:
The 'bool' keyword, which is defined in the 'stdbool.h' header, represents boolean values in C.
12. What is the output of the following C code?
printf("%lu", sizeof(float));
Answer:
Explanation:
Typically, the size of 'float' in C is 4 bytes. However, it can vary depending on the system.
13. Which of the following is not a valid integer data type in C?
Answer:
Explanation:
In C, 'byte' is not a valid integer data type. The valid integer types are 'short', 'int', and 'long'.
14. What is the default type for a floating-point constant in C?
Answer:
Explanation:
In C, a floating-point constant without a suffix is considered a 'double'.
15. Which data type is used for storing a single byte in C?
Answer:
Explanation:
The 'char' data type in C is used to store a single byte of data.
16. What will be the range of a signed char data type in C?
Answer:
Explanation:
A signed char can hold values from -128 to 127.
17. How many bytes are allocated for a 'short int' data type in C?
Answer:
Explanation:
A 'short int' typically occupies 2 bytes in C, though this may vary with different system architectures.
18. What is the size of the 'long int' data type in C on a standard 32-bit system?
Answer:
Explanation:
On a standard 32-bit system, the size of a 'long int' is generally 4 bytes.
19. What does the 'unsigned' modifier do to an integer data type in C?
Answer:
Explanation:
The 'unsigned' modifier means the integer variable can only store non-negative values.
20. What is the output of the following C code snippet?
printf("%zu", sizeof(double));
Answer:
Explanation:
Typically, the size of 'double' in C is 8 bytes, though this can vary depending on the system.
21. What data type should be used for a variable that needs to store very large floating-point numbers in C?
Answer:
Explanation:
'long double' is the most suitable for storing very large floating-point numbers due to its higher precision and range.
22. In C, what will be the size of a pointer variable on a 64-bit system?
Answer:
Explanation:
On a 64-bit system, a pointer variable typically occupies 8 bytes, regardless of the data type it points to.
23. Which data type is best suited for storing ASCII values in C?
Answer:
Explanation:
The 'char' data type is best suited for storing ASCII values, as each ASCII character is represented by a single byte.
24. What will be the range of an 'unsigned int' data type in C?
Answer:
Explanation:
An 'unsigned int' in C typically has a range from 0 to 4294967295 on a 32-bit system.
25. What is the size of a 'wchar_t' data type in C?
Answer:
Explanation:
The size of 'wchar_t' varies depending on the compiler and the system. It is typically 2 or 4 bytes.
Comments
Post a Comment
Leave Comment