পরীক্ষা আর্কাইভ

৪৯তম বিসিএস ⎯ কম্পিউটার সায়েন্স (CSE) [৯৭১]

পরীক্ষা৪৯তম বিসিএস ⎯ কম্পিউটার সায়েন্স (CSE) [৯৭১]তারিখতারিখ অনির্ধারিতসময়18 minutes
মোট প্রশ্ন৩০
সিলেবাস
Exam 3 Introduction to programming; problem-solving techniques; programming paradigms; Structured and object-oriented programming; Language basics; program design; debugging; Programming in C/C++ and JAVA (overview) [Source: Class–2 and relevant books]
ঘনত্ব
উত্তর
উত্তরিতবর্তমানপুনরায় দেখুনঅসম্পূর্ণ

৪৯তম বিসিএস ⎯ কম্পিউটার সায়েন্স (CSE) [৯৭১]

৪৯তম বিসিএস ⎯ কম্পিউটার সায়েন্স (CSE) [৯৭১] · তারিখ অনির্ধারিত · ৩০ প্রশ্ন

.
Which is true? 
  1. Compiler executes line by line 
  2. Interpreter translates the entire program before execution
  3. Assembler translates high-level code to machine code 
  4. None of the above
ব্যাখ্যা

Compiler → translates whole program at once.
Interpreter → translates line by line.
Assembler → works with assembly language, not high-level

.
Which of the following will detect logical errors in a C program?
  1. Compiler
  2. Interpreter
  3. Debugger
  4. Linker
ব্যাখ্যা

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.

.
Which of the following variable names is valid in C? 
  1. float 
  2. total$
  3. 1data
  4. _sum 
ব্যাখ্যা

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). 

.
In a 32-bit C compiler, what is the typical size of double data type?
  1. 2 bytes 
  2. 4 bytes
  3. 8 bytes 
  4. 16 bytes
ব্যাখ্যা

​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 

.
What will be the output after execution the following C codes ?
int main()
{
int a = 1;
printf("%d", !a++); 
}
  1. 1
  2. Compiler error
  3. Undefined
ব্যাখ্যা

Here,
​ a++ (post increment) → value used = 1, 
​then a = 2.  
​!1 = 0 ( '!' is logical NOT operator)

​​Answer: a) 0

.
What does the following code print?

int main()
{
int x;
printf("%d\n", (x = 3) + 4);
}
  1. Compilation error 
  2. Garbage value
ব্যাখ্যা

In C, an assignment is an expression, and it returns the value assigned.
So: (x = 3) returns 3 → 3 + 4 = 7

.
What is the term used for a block of code that is executed repeatedly until a certain condition is met? 
  1. Function 
  2. Loop
  3. Condition 
  4. Variable
ব্যাখ্যা

 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.

.
What is an infinite loop in programming?
  1. A loop that repeats a fixed number of times
  2. A loop that never terminates because its condition is always true
  3. A loop that performs a single iteration
  4. A loop that has no body
ব্যাখ্যা

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
}

.
Which operator is used to get the address of a variable in C? 
  1. &
  2. - > 
  3. %
ব্যাখ্যা

​ &var → gives address. *ptr → value at pointer (dereferencing).
​ -> → structure pointer member access. % → modulus operator.

১০.
During software development, the activity of detecting errors is called:
  1. Debugging 
  2. Verification
  3. Compilation 
  4. Testing 
ব্যাখ্যা

Testing → finding errors/bugs. 
Debugging → fixing errors after finding them.
Compilation → translation, not error detection.
Verification → ensures software meets design requirements.

১১.
What will this print? 
int a = 10, b = 20;
printf("%d", a > b ? a : b > a ? b : a);
  1. 20
  2. 10
  3. Undefined 
ব্যাখ্যা

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)

১২.
Which type of loop in programming always executes its body at least once, even if the condition is initially false?
  1. For loop 
  2. While loop
  3. Do-while loop
  4. Foreach loop 
ব্যাখ্যা

Do-while loop A do-while loop always executes its body at least once, as the condition is checked after the loop body.

১৩.
Which of the following loops is infinite? 
  1. while(x < 10) 
            {

            }
  2. for( ; ; )  
    {  

    }
  3.  while(0) 
         {

         }
  4. for(i = 0; i < 5; i++)
        {

        }
ব্যাখ্যা

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.

১৪.
What will be the output?
int i = 0; 
while(1) {
           if(i == 3)
          break;
         printf("%d ", i);
         i++;
         } 
  1. 0 1 2 
  2. 0 1 2 3
  3. 1 2 3 
  4. Infinite loop 
ব্যাখ্যা

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 

১৫.
What will happens here for following C codes  ?
 #include<stdio.h>
int main()
{
int x = 5; int x = 10;
printf("%d", x);
return 0;
  1. Prints 10 
  2. Compilation error
  3. Prints 5 
  4. Undefined behavior 
ব্যাখ্যা

Answer: B) Compilation error 
​Explanation: Cannot redeclare variable x in the same scope. This is a violation of C's scoping rules

১৬.
Which of the following is NOT a valid loop control statement in C?
  1. break 
  2. continue 
  3. exit()
  4. stop 
ব্যাখ্যা

 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

১৭.
What is the purpose of the continue statement in a loop? 
  1. To exit the loop completely 
  2. To skip the current iteration and continue with the next iteration of the loop
  3. To terminate the program 
  4. To pause the execution 
ব্যাখ্যা

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.

১৮.
What will be the output of the following C code?
int main() 
{ int i;
for(i = 0; i < 5; i++)
 { if(i == 4)
continue;
printf("%d ", i+1); }
return 0;}
  1. 0 1 2 3 4
  2. 1 2 3 5
  3. 0 1 2 4 5
  4. 1 2 3 4
ব্যাখ্যা

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

১৯.
Which of the following is the correct syntax to declare an array in C? 
  1. array int a[10]; 
  2. int a[10]; 
  3. int[10] a;
  4. a int[10];
ব্যাখ্যা

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.

২০.
How do you access the third element in an array arr? 
  1. arr[3] 
  2. arr(3) 
  3. arr[2]
  4. arr(2)
ব্যাখ্যা

 Answer: C) arr[2] 
 Since array indexing starts at 0, the third element is at index 2.

২১.
In which case is a union preferable over a struct? 
  1. When all members need to be stored at the same time 
  2. When only one member is used at a time 
  3. When memory usage is not a concern 
  4. When you need to create a linked list
ব্যাখ্যা

 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

২২.
What will the following code print when fun(3) is called?
void fun(int n)
{ if (n > 0)
{ printf("%d ", n); fun(n - 1); }
}
int main(){
fun(3);
return 0; }
  1. 3 2 1
  2. 1 2 3 
  3. 0 1 2 3 
  4. Infinite loop
ব্যাখ্যা

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.

২৩.
What is the key difference between a struct and a union?
  1. Struct uses more memory than union 
  2. Union uses more memory than struct
  3. Struct members share memory; union members don’t 
  4. They behave the same way
ব্যাখ্যা

 ✅ 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

২৪.
Which programming paradigm emphasizes the division of problems into functions and procedures?
  1. Object-Oriented Programming
  2. Structured Programming 
  3. Functional Programming 
  4. Event-Driven Programming 
ব্যাখ্যা

Answer: B) Structured Programming 
Structured programming solves problems by breaking them into small, logical procedures or functions — not objects.

২৫.
Which of the following is not a principle of Object-Oriented Programming? 
  1. Encapsulation
  2. Polymorphism
  3. Inheritance
  4. Recursion
ব্যাখ্যা

Answer: D) Recursion 
Recursion is a general programming technique, not specific to OOP. The four pillars of OOP are: Encapsulation, Inheritance, Polymorphism, and Abstraction.

২৬.
Which of the following supports data hiding and encapsulation?
  1. Assembly 
  2. Java
  3. Pascal 
ব্যাখ্যা

Answer: C) Java 
Java is an object-oriented language that supports data hiding via access specifiers (e.g., private, public) and encapsulation via classes.

২৭.
What is Function Overloading in OOP?
  1. Defining multiple functions with the same name but different parameters
  2. Defining multiple functions with the same name and same parameters
  3. Using one function inside another
  4. Calling a function multiple times in a program
ব্যাখ্যা

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.

২৮.
What does method overloading improve in a program?
  1. Memory usage 
  2. Program speed 
  3. Code readability and reusability
  4. Compilation time
ব্যাখ্যা

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

২৯.
What is Polymorphism in OOP? 
  1. Creating different classes
  2. Having multiple forms of a function or object 
  3. Encapsulating data
  4. Inheriting properties from parent class 
ব্যাখ্যা

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.

৩০.
What is method overriding? 
  1. Defining two methods with same name and different parameters
  2. Using a method without parameters 
  3. Redefining a base class method in a derived class 
  4. Defining the same method in different classes with no relation
ব্যাখ্যা

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).