Home Subjects C Programming

C Programming

C language from basics to advanced placement prep

291 Q 10 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 271–280 of 291
Topics in C Programming
Q.271 Easy Basics & Syntax
In C, which of the following correctly declares a pointer to an integer?
A int *ptr;
B *int ptr;
C int& ptr;
D pointer int *;
Correct Answer:  A. int *ptr;
EXPLANATION

The correct syntax is 'int *ptr;' where * indicates ptr is a pointer to int.

Test
Q.272 Easy Basics & Syntax
Which header file is required to use the malloc() function?
A
B
C
D
Correct Answer:  B.
EXPLANATION

malloc() and other dynamic memory allocation functions are declared in <stdlib.h>.

Test
Q.273 Easy Basics & Syntax
What is the output of: char c = 65; printf("%c", c);
A 65
B A
C Invalid output
D Compilation error
Correct Answer:  B. A
EXPLANATION

%c format specifier prints the character representation of ASCII value 65, which is 'A'.

Test
Q.274 Easy Basics & Syntax
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.

Test
Q.275 Easy Basics & Syntax
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.

Test
Q.276 Easy Basics & Syntax
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.

Test
Q.277 Easy Basics & Syntax
Which escape sequence is used to print a newline character in C?
A \t
B \n
C \r
D \0
Correct Answer:  B. \n
EXPLANATION

The escape sequence \n represents a newline character that moves the cursor to the next line.

Test
Q.278 Easy Basics & Syntax
What is the default return type of the main() function in C?
A void
B int
C float
D char
Correct Answer:  B. int
EXPLANATION

The main() function implicitly returns int type, which indicates the program's exit status (0 for success, non-zero for failure).

Test
Q.279 Easy Basics & Syntax
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.

Test
Q.280 Easy Basics & Syntax
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.

Test
IGET
IGET AI
Online · Exam prep assistant
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips