Home Subjects C Programming Basics & Syntax

C Programming
Basics & Syntax

C language from basics to advanced placement prep

100 Q 10 Topics Take Test
Advertisement
Difficulty: All Easy Medium Hard 51–60 of 100
Topics in C Programming
Q.51 Medium Basics & Syntax
In C, which operator has the highest precedence?
A Multiplicative operators (*, /, %)
B Postfix operators (++, --)
C Additive operators (+, -)
D Assignment operators (=)
Correct Answer:  B. Postfix operators (++, --)
EXPLANATION

Postfix operators ([], ., ->, ++, --) have the highest precedence in C, followed by unary and then binary operators.

Take Test
Q.52 Medium Basics & Syntax
What is the primary purpose of the 'volatile' keyword in C?
A To prevent variable modification
B To inform the compiler that a variable's value can change unexpectedly
C To allocate memory dynamically
D To declare function pointers
Correct Answer:  B. To inform the compiler that a variable's value can change unexpectedly
EXPLANATION

The 'volatile' keyword tells the compiler not to optimize accesses to a variable, as its value can change from external sources (hardware, signals, etc.).

Take Test
Q.53 Medium Basics & Syntax
Which of the following correctly represents a string literal in C?
A char str = 'Hello';
B char str[] = "Hello";
C string str = "Hello";
D char *str = 'Hello';
Correct Answer:  B. char str[] = "Hello";
EXPLANATION

Strings in C are represented using double quotes and stored in character arrays. Single quotes are for single characters.

Take Test
Q.54 Medium Basics & Syntax
What will be the output of the expression: 5/2 in C (considering integer division)?
A 2.5
B 3
C 2
D Error
Correct Answer:  C. 2
EXPLANATION

In C, when both operands are integers, division performs integer division, discarding the fractional part. 5/2 = 2.

Take Test
Q.55 Medium Basics & Syntax
What is the range of values for 'signed char' in C (assuming 8-bit char)?
A 0 to 255
B -128 to 127
C -256 to 255
D 0 to 127
Correct Answer:  B. -128 to 127
EXPLANATION

A signed char is 1 byte (8 bits) and can represent values from -128 to 127 using two's complement representation.

Take Test
Q.56 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.

Take Test
Q.57 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).

Take Test
Q.58 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.

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

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

Take Test
IGET
iget AI
Online · Ask anything about exams
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