C Programming — Basics & Syntax
C language from basics to advanced placement prep
100 Questions 10 Topics Take Test
Advertisement
Showing 41–50 of 100 questions in Basics & Syntax
Q.41 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.

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

Take Test
Q.43 Hard Basics & Syntax
Which of the following best describes the 'register' storage class in modern C compilers?
A Guarantees storage in CPU register
B A hint to the compiler to optimize variable storage; compiler may ignore it
C Forces the variable to be global
D Automatically allocates memory on the stack
Correct Answer:  B. A hint to the compiler to optimize variable storage; compiler may ignore it
EXPLANATION

The 'register' keyword is a hint for compiler optimization. Modern compilers often ignore it as they have sophisticated optimization strategies.

Take Test
Q.44 Hard Basics & Syntax
What is the output of: printf("%d", (int)3.7);?
A 3.7
B 3
C 4
D Error
Correct Answer:  B. 3
EXPLANATION

Type casting (int)3.7 truncates the decimal part, converting 3.7 to 3. The fractional part is discarded.

Take Test
Q.45 Hard Basics & Syntax
Consider a function declared as 'static int func()'. What is the scope of this function?
A Global scope across all files
B Limited to the current file only
C Only within the function where it's declared
D Limited to the current block
Correct Answer:  B. Limited to the current file only
EXPLANATION

When 'static' is applied to a function at file scope, it restricts the function's visibility to that translation unit (file) only.

Take Test
Q.46 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.47 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.48 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.49 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
Q.50 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
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