উত্তর
ব্যাখ্যা
Compiler → translates whole program at once.
Interpreter → translates line by line.
Assembler → works with assembly language, not high-level
৪৯তম বিসিএস ⎯ কম্পিউটার সায়েন্স (CSE) [৯৭১] · তারিখ অনির্ধারিত · ৩০ প্রশ্ন
Compiler → translates whole program at once.
Interpreter → translates line by line.
Assembler → works with assembly language, not high-level
Compiler & Interpreter detects syntax errors only (e.g., missing ;, undeclared variable).
Logical errors (wrong result even though program runs) → only caught by debugging during execution.
float (here, float is a keyword, keyword is not allowed in variable declaration)
$ is not allowed in identifiers
1data (variable name cannot start with digit).
_sum valid (Underscore is allowed).
float → 4 bytes (32-bit precision).
double → 8 bytes (64-bit precision).
long double → often 10, 12, or 16 bytes depending on compiler.
Always check with sizeof() since exact size may vary across compilers.
Answer: c) 8 bytes
Here,
a++ (post increment) → value used = 1,
then a = 2.
!1 = 0 ( '!' is logical NOT operator)
Answer: a) 0
In C, an assignment is an expression, and it returns the value assigned.
So: (x = 3) returns 3 → 3 + 4 = 7
Answer: b) Loop.
– A loop is a block of code that is executed repeatedly until a certain condition is met. There are different types of loops in programming languages, such as for loop, while loop, and do-while loop.
An infinite loop in programming is a loop that never terminates — it keeps running forever (or until the program is forcibly stopped.
It happens when
1. Condition is always true
while(1) {
//This loop will run forever
}
2.Missing update
int i = 0;
while (i < 10) {
// i is never updated -> infinite loop
}
3. Mistaken logic
int i = 10;
while (i != 0) {
i += 2;
// i never becomes 0 -> infinite
}
&var → gives address. *ptr → value at pointer (dereferencing).
-> → structure pointer member access. % → modulus operator.
Testing → finding errors/bugs.
Debugging → fixing errors after finding them.
Compilation → translation, not error detection.
Verification → ensures software meets design requirements.
Ternary operator is right-associative.
Expression = a > b ? a : (b > a ? b : a).
Since a > b is false
then check (b > a ? b : a)
since b>a true
then print 20. (b=20)
Do-while loop A do-while loop always executes its body at least once, as the condition is checked after the loop body.
for(;;) is a valid infinite loop in C.
It is equivalent to while(1) that is always true. The code block inside the loop is executed repeatedly and infinitely.
Option A and D are conditional loops with end conditions.
Option C (while(0)) never runs because it is always false.
here, The loop starts at i = 0, and prints i until i == 3, at which point break exits the loop.
It prints 0, 1, 2, then exits.
So answer a) 0 1 2
Answer: B) Compilation error
Explanation: Cannot redeclare variable x in the same scope. This is a violation of C's scoping rules
Answer: D) stop
stop is not a valid C keyword.
Valid loop control statements: break, continue, and exit()
break
Purpose: Immediately exits the loop.
Use case: When a condition is met and you want to stop looping
continue
Purpose: Skips the current iteration and continues with the next one.
Use case: When you want to skip specific values inside a loop
exit() is a standard library function that is used to terminate a program immediately
Correct Answer: B
The continue statement is used inside loops like for, while, or do-while. When the continue statement is encountered, the loop skips the rest of the code for the current iteration and proceeds directly to the next iteration of the loop.
#include
int main() {
for (int i = 1; i <= 5; i++) {
if (i == 3) {
continue;
}
printf("%d ", i);
}
return 0;}
Output:
1 2 4 5
When i == 3, the continue statement is executed.
This skips the printf for that iteration.
So, 3 is not printed.
All other values are printed normally.
When i == 0, condition true and printf statement will be executed so 0+1= 1 is printed.
When i == 1, condition true and printf statement will be executed so 1+1= 2 is printed
When i == 2, condition true and printf statement will be executed so 2+1=3 is printed
When i == 3 condition true and printf statement will be executed so 3+1= 4 is printed
When i == 4, condition true and continue statement will be executed and it skips the printf statement, so 4+1= 5 is not printed.
When i == 5 condition false and program jump to the outside of the loop.
So answer is D: 1 2 3 4
Answer: B) int a[10];
In C, arrays are declared using the format: data_type array_name[size];
Example: int a[10]; declares an array of 10 integers.
Answer: C) arr[2]
Since array indexing starts at 0, the third element is at index 2.
Answer: B) When only one member is used at a time
Explanation: Use unions when you only need to store one of many possible types/values at any given time . It saves memory
Answer: 3 2 1
This is pre-recursive printing → printf happens before the recursive call.
So it prints 3, then calls fun(2), then 2, then 1.
✅ Answer: A) Struct uses more memory than union
Explanation:
In a structure, each member gets its own memory
In a union, all members share the same memory space
Size of union = size of the largest member
Answer: B) Structured Programming
Structured programming solves problems by breaking them into small, logical procedures or functions — not objects.
Answer: D) Recursion
Recursion is a general programming technique, not specific to OOP. The four pillars of OOP are: Encapsulation, Inheritance, Polymorphism, and Abstraction.
Answer: C) Java
Java is an object-oriented language that supports data hiding via access specifiers (e.g., private, public) and encapsulation via classes.
A) Defining multiple functions with the same name but different parameters
Function Overloading allows multiple functions with the same name but different parameter types or counts in the same scope.
int add(int a, int b);
float add(float a, float b);
here, function name same (add) but different parameters.
Answer: C) Code readability and reusability
Method overloading improves readability and reusability , since you can use the same name for logically similar operations with different inputs.
Method overloading means defining multiple methods with the same name in the same class, but with different parameter lists (type, number, or order).
class Example {
void show(int a) {
System.out.println("Integer: " + a);
}
void show(String s) {
System.out.println("String: " + s);
}
}
Here, show() is overloaded — one version takes an int, the other a String
Answer: B) Having multiple forms of a function or object.
Polymorphism means "many forms". It allows a function or object to behave differently based on the context,
like function overloading or method overriding.
Answer: C) Redefining a base class method in a derived class
Method overriding is an important concept in Object-Oriented Programming (OOP) where a subclass (child class) provides a specific implementation of a method that is already defined in its superclass (parent class).