C Programming
C language from basics to advanced placement prep
1,000 Questions 10 Topics Take Test
Advertisement
Showing 971–980 of 1,000 questions
Q.971 Medium Basics & Syntax
What is the output of the following code?
#include
int main() {
int a = 5, b = 10;
a = b++;
printf("%d %d", a, b);
return 0;
}
A 5 10
B 10 11
C 11 11
D 10 10
Correct Answer:  B. 10 11
EXPLANATION

b++ returns the current value of b (10) before incrementing, so a = 10. Then b increments to 11.

Take Test
Q.972 Medium Basics & Syntax
Which of the following correctly initializes a 2D array?
A int arr[3][3] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
B int arr[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
C Both A and B
D Neither A nor B
Correct Answer:  C. Both A and B
EXPLANATION

Both syntaxes are valid in C. The first uses row-major order without explicit braces, the second uses explicit nested braces.

Take Test
Q.973 Medium Basics & Syntax
What will be the output of the following code?
#include
int main() {
int x = 10, y = 20;
int *p = &x, *q = &y;
*p = *q;
printf("%d %d", x, y);
return 0;
}
A 10 20
B 20 20
C 10 10
D 20 10
Correct Answer:  B. 20 20
EXPLANATION

*p = *q assigns the value of y (20) to x through the pointer p. So x becomes 20, y remains 20.

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

Take Test
Q.975 Easy Basics & Syntax
What is the output of the following code?
#include
int main() {
int arr[] = {10, 20, 30};
printf("%d", *(arr + 1));
return 0;
}
A 10
B 20
C 30
D Error
Correct Answer:  B. 20
EXPLANATION

arr + 1 points to the second element. Dereferencing with * gives the value 20.

Take Test
Advertisement
Q.976 Easy Basics & Syntax
Which keyword is used to create a variable that cannot be modified after initialization?
A static
B const
C volatile
D extern
Correct Answer:  B. const
EXPLANATION

The 'const' keyword creates a constant variable that cannot be modified after initialization. The compiler enforces this at compile time.

Take Test
Q.977 Medium Basics & Syntax
What will be printed by the following code?
#include
int main() {
float f = 0.1 + 0.2;
if(f == 0.3)
printf("Equal");
else
printf("Not Equal");
return 0;
}
A Equal
B Not Equal
C Compiler Error
D Runtime Error
Correct Answer:  B. Not Equal
EXPLANATION

Due to floating-point precision limitations, 0.1 + 0.2 does not exactly equal 0.3 in binary representation.

Take Test
Q.978 Medium Basics & Syntax
What is the size of the following structure in bytes (assuming 32-bit system)?
struct Point {
char c;
int x;
double d;
}
A 13
B 16
C 17
D 20
Correct Answer:  B. 16
EXPLANATION

Due to structure padding and alignment: char (1 byte) + padding (3 bytes) + int (4 bytes) + double (8 bytes) = 16 bytes.

Take Test
Q.979 Easy Basics & Syntax
Which of the following is a valid variable name in C?
A 2variable
B _var123
C var-name
D var name
Correct Answer:  B. _var123
EXPLANATION

Variable names must start with a letter or underscore, not a digit. They cannot contain hyphens or spaces. _var123 is the only valid name.

Take Test
Q.980 Hard Basics & Syntax
What will be the output of the following code?
#include
int main() {
int x = 5;
printf("%d", ++x + x++);
return 0;
}
A 12
B 13
C 11
D Undefined behavior
Correct Answer:  D. Undefined behavior
EXPLANATION

The expression ++x + x++ involves modifying x multiple times without an intervening sequence point, leading to undefined behavior in C.

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