Showing 281–290 of 303 questions
In C, what is the size of the 'char' data type?
A
1 bit
B
1 byte
C
2 bytes
D
4 bytes
Correct Answer:
B. 1 byte
EXPLANATION
By C standard, sizeof(char) is always 1 byte, regardless of platform.
Which of the following is NOT a valid C identifier?
A
_variable123
B
123variable
C
variable_123
D
__var__
Correct Answer:
B. 123variable
EXPLANATION
Identifiers cannot start with a digit. They must start with a letter (a-z, A-Z) or underscore.
What is the size of the 'int' data type in a 32-bit system according to C standard?
A
2 bytes
B
4 bytes
C
8 bytes
D
Platform dependent
Correct Answer:
D. Platform dependent
EXPLANATION
The size of 'int' is implementation-defined and depends on the compiler and platform, though it is typically 4 bytes on 32-bit systems.
Which escape sequence is used to print a newline character in C?
EXPLANATION
The escape sequence \n represents a newline character that moves the cursor to the next line.
What is the default return type of the main() function in C?
A
void
B
int
C
float
D
char
EXPLANATION
The main() function implicitly returns int type, which indicates the program's exit status (0 for success, non-zero for failure).
Which of the following variable names is valid in C?
A
2variable
B
var-iable
C
_variable123
D
var iable
Correct Answer:
C. _variable123
EXPLANATION
Variable names in C must start with a letter or underscore, followed by alphanumeric characters or underscores. '_variable123' is valid, while '2variable' starts with digit, 'var-iable' has hyphen, and 'var iable' has space.
What does the 'sizeof' operator return in C?
A
The memory address of a variable
B
The number of bytes occupied by a data type or variable
C
The value of the variable
D
The type of the variable
Correct Answer:
B. The number of bytes occupied by a data type or variable
EXPLANATION
The sizeof operator returns the size in bytes of a data type or the allocated memory for a variable.
Which header file is required to use the printf() function in C?
A
#include
B
#include
C
#include
D
#include
Correct Answer:
B. #include
EXPLANATION
The stdio.h (Standard Input Output) header file contains declarations for printf() and scanf() functions.
What is the size of 'char' data type in C?
A
2 bytes
B
4 bytes
C
1 byte
D
8 bytes
Correct Answer:
C. 1 byte
EXPLANATION
The 'char' data type in C occupies 1 byte of memory and can store a single character.
Which of the following is the correct syntax to declare a pointer to an integer in C?
A
int *ptr;
B
int& ptr;
C
*int ptr;
D
ptr *int;
Correct Answer:
A. int *ptr;
EXPLANATION
In C, a pointer to an integer is declared using 'int *ptr;' where '*' indicates pointer declaration.