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 231–240 of 291
Topics in C Programming
Q.231 Easy Control Flow
What is the behavior of goto in C?
A It transfers control to a labeled statement
B It exits the program
C It skips the next statement
D It is not part of C standard
Correct Answer:  A. It transfers control to a labeled statement
EXPLANATION

goto transfers program control to a labeled location, though it's discouraged for code readability.

Test
Q.232 Easy Control Flow
Analyze the ternary operator: int x = (5 > 3) ? 10 : 20; What is the value of x?
A 10
B 20
C 1
D Compilation error
Correct Answer:  A. 10
EXPLANATION

Since 5 > 3 is true, the ternary operator returns 10, so x = 10.

Test
Q.233 Easy Control Flow
What is the difference between 'break' and 'continue' in loops?
A break exits the loop, continue skips to next iteration
B continue exits the loop, break skips to next iteration
C Both are identical
D break is only for switch, continue is only for loops
Correct Answer:  A. break exits the loop, continue skips to next iteration
EXPLANATION

break terminates the loop entirely, while continue jumps to the next iteration without executing remaining statements.

Test
Q.234 Easy Control Flow
What is the output of this code?
for (int i = 0; i < 3; i++)
printf("%d ", i);
A 0 1 2
B 1 2 3
C 0 1 2 3
D Nothing prints
Correct Answer:  A. 0 1 2
EXPLANATION

The loop runs from i=0 to i=2 (i < 3), printing '0 1 2 '.

Test
Q.235 Easy Control Flow
Which of the following is NOT a valid control flow statement in C?
A switch
B foreach
C while
D for
Correct Answer:  B. foreach
EXPLANATION

foreach is not a standard C control flow statement. C has if-else, switch, for, while, do-while, and goto.

Test
Q.236 Easy Control Flow
What will be the output of the following C code?
int x = 5;
if (x > 3)
printf("A");
else
printf("B");
A A
B B
C Compilation error
D No output
Correct Answer:  A. A
EXPLANATION

Since x = 5 and 5 > 3 is true, the if block executes and prints 'A'.

Test
In C programming, when you declare a variable as 'const int x = 5;', what happens if you try to modify it within the program?
A The compiler will generate a warning but allow modification at runtime
B The compiler will generate a compilation error and prevent modification
C The variable will be modified but will revert to original value after each operation
D The modification will be allowed only in the main() function
Correct Answer:  B. The compiler will generate a compilation error and prevent modification
EXPLANATION

The 'const' keyword creates a read-only variable. Once initialized, attempting to modify a const variable results in a compilation error (error: assignment of read-only variable). This is enforced at compile-time, not runtime.

Test
Which of the following variable declarations will occupy the LEAST memory?
A unsigned int x;
B float y;
C char z;
D double w;
Correct Answer:  C. char z;
EXPLANATION

char data type typically occupies 1 byte, which is the minimum. int is 4 bytes, float is 4 bytes, and double is 8 bytes on most systems.

Test
Which keyword is used to declare a variable that cannot be modified after initialization?
A static
B volatile
C const
D extern
Correct Answer:  C. const
EXPLANATION

The 'const' keyword declares a constant variable whose value cannot be modified after initialization. Attempting to modify it results in a compile-time error.

Test
What is the size of a 'long long int' variable in C on a 64-bit system?
A 4 bytes
B 8 bytes
C 16 bytes
D Compiler dependent
Correct Answer:  B. 8 bytes
EXPLANATION

A 'long long int' is guaranteed to be at least 64 bits (8 bytes) by the C99 standard on all systems including 64-bit architectures.

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