Home Subjects C Programming Basics & Syntax

C Programming
Basics & Syntax

C language from basics to advanced placement prep

27 Q 10 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 11–20 of 27
Topics in C Programming
Q.11 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.12 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.13 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.14 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.15 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.16 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
Q.17 Easy Basics & Syntax
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.

Test
Q.18 Easy Basics & Syntax
What is the output of the following code?
#include
int main() {
char c = 'A';
printf("%d", c);
return 0;
}
A 65
B A
C 1
D Error
Correct Answer:  A. 65
EXPLANATION

The %d format specifier prints the ASCII value of the character. 'A' has ASCII value 65.

Test
Q.19 Easy Basics & Syntax
What will be printed by the following code?
#include
int main() {
char str[] = "Hello";
printf("%c", str[1]);
return 0;
}
A H
B e
C l
D o
Correct Answer:  B. e
EXPLANATION

String indexing starts at 0. str[0] = 'H', str[1] = 'e'.

Test
Q.20 Easy Basics & Syntax
In C, which of the following statements about pointers is TRUE?
A Pointers always occupy 4 bytes of memory
B A pointer stores the memory address of a variable
C Pointers cannot be used with arrays
D Dereferencing a null pointer is safe
Correct Answer:  B. A pointer stores the memory address of a variable
EXPLANATION

A pointer stores the memory address of a variable. Pointer size depends on the system architecture, not always 4 bytes.

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