C Programming
C language from basics to advanced placement prep
499 Questions 10 Topics Take Test
Advertisement
Showing 471–480 of 499 questions
Q.471 Medium Basics & Syntax
What does the 'extern' keyword indicate in C?
A A variable exists in another source file
B A variable is local to a function
C A variable cannot be modified
D A variable is allocated on the stack
Correct Answer:  A. A variable exists in another source file
EXPLANATION

'extern' declares a variable or function that is defined in another translation unit (source file).

Take Test
Q.472 Medium Basics & Syntax
What will be the result of the bitwise operation: 5 & 3 in C?
A 1
B 7
C 6
D 4
Correct Answer:  A. 1
EXPLANATION

5 (binary 101) & 3 (binary 011) = 001 (binary) = 1. Bitwise AND operates on each bit position.

Take Test
Q.473 Medium Basics & Syntax
In C, what is the correct way to pass a variable by reference using pointers?
A void func(int var) { var = 10; }
B void func(int &var) { var = 10; }
C void func(int *var) { *var = 10; }
D void func(int *var) { var = 10; }
Correct Answer:  C. void func(int *var) { *var = 10; }
EXPLANATION

C uses pointers for pass-by-reference. The dereference operator '*var' accesses the actual variable. C++ supports references (&var), but C does not.

Take Test
Q.474 Medium Basics & Syntax
What is the difference between 'break' and 'continue' statements in C?
A 'break' stops execution while 'continue' skips iteration
B Both have the same function
C 'continue' stops execution while 'break' skips iteration
D Neither has practical use in loops
Correct Answer:  A. 'break' stops execution while 'continue' skips iteration
EXPLANATION

'break' terminates the loop entirely, while 'continue' skips the current iteration and moves to the next one.

Take Test
Q.475 Medium Basics & Syntax
Which of the following is a correct way to read a string from user input avoiding buffer overflow?
A scanf("%s", str);
B scanf("%10s", str);
C gets(str);
D scanf("%[^ ]s", str);
Correct Answer:  B. scanf("%10s", str);
EXPLANATION

Using scanf("%10s", str) limits input to 10 characters, preventing buffer overflow. The gets() function is deprecated and unsafe.

Take Test
Advertisement
Q.476 Medium Basics & Syntax
What does the 'const' keyword do when applied to a pointer?
A Makes the pointer value constant only
B Makes the pointed data constant only
C Can make either or both constant depending on placement
D Has no effect in C
Correct Answer:  C. Can make either or both constant depending on placement
EXPLANATION

'const int *ptr' makes the data constant, 'int * const ptr' makes the pointer constant, and 'const int * const ptr' makes both constant.

Take Test
Q.477 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.478 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.479 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.480 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
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