Dhaka Power Distribution Company Limited

Post: Technical (Computer technology)
Subject code: 155; Mark: 80
1.(a) Find the output of this program.
#include
int main() {
int n = 4;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n - i; j++) {
printf(" ");
}
for (int j = 1; j <= i; j++) {
printf("*");
}
printf("\n");
}
return 0;
}

The output is:

*
**
***
****

**Explanation:**

* `i = 1` → 3 spaces + 1 `*`
* `i = 2` → 2 spaces + 2 `*`
* `i = 3` → 1 space + 3 `*`
* `i = 4` → 0 spaces + 4 `*`

1.(b) Class C has some features. Class D uses all features of Class C and has some extra features of its own. Identify the concept used here in Object-Oriented Programming (OOP) and explain with an example.

Concept: Inheritance

In Object-Oriented Programming (OOP), Inheritance is a mechanism where one class, called the Derived Class, acquires the properties and methods of another class, called the Base Class. The Derived Class can also have some additional features of its own.

Example:

#include <iostream>
using namespace std;

class C {
public:
    void feature1() {
        cout << "Feature of Class C" << endl;
    }
};

class D : public C {
public:
    void feature2() {
        cout << "Extra feature of Class D" << endl;
    }
};

int main() {
    D obj;
    obj.feature1();  // Inherited from Class C
    obj.feature2();  // Own feature of Class D

    return 0;
}

Here, Class D inherits the feature of Class C and also has its own additional feature. Therefore, the concept used here is Inheritance.

2.(a) Let A = {1,2,3,4,5,6,7,8}. If five integers are selected from A, prove that at least one pair of selected integers has a sum of 9. Use the Pigeonhole Principle.

Solution:

Given, A = {1, 2, 3, 4, 5, 6, 7, 8}.

We need to select five integers from A and prove that at least one pair of selected integers has a sum of 9.

The numbers in A can be divided into the following four pairs, where each pair has a sum of 9:

(1, 8), (2, 7), (3, 6), (4, 5)

Here, the 4 pairs are the pigeonholes.

When 5 integers are selected, they are the pigeons.

By the Pigeonhole Principle, if 5 pigeons are placed into 4 pigeonholes, then at least one pigeonhole must contain at least 2 pigeons.

Therefore, at least one of the four pairs must have both of its integers selected.

Each pair has a sum of 9. Hence, at least one pair of selected integers has a sum of 9.

Therefore, proved by the Pigeonhole Principle.

2.(b) Simplify using K-map: F(A,B,C) = A'BC' + A'BC + AB'C' + AB'C + ABC' + ABC

3.(a) Create an example of a trigger.

Example of a Trigger A Trigger is a database program that automatically executes when a specified event, such as INSERT, UPDATE, or DELETE, occurs on a table. Example: The following trigger automatically records the date and time whenever a new employee is inserted into the Employee table.

CREATE TRIGGER employee_insert
AFTER INSERT ON Employee
FOR EACH ROW
BEGIN
    INSERT INTO Employee_Log(employee_id, log_date)
    VALUES (NEW.employee_id, NOW());
END;

Here, the trigger employee_insert automatically executes after a new record is inserted into the Employee table and stores the employee ID and insertion time in the Employee_Log table.

3.(b) Consider the following tables: Customer(customerID, name), Accounts(accountID, customerID), Orders(orderID, accountID, orderAmount). Write an SQL query to display customerID, name, and total order amount of all customers whose total order amount is greater than 5000.
SELECT c.customerID, c.name, SUM(o.orderAmount) AS total_order_amount
FROM Customer c
JOIN Accounts a ON c.customerID = a.customerID
JOIN Orders o ON a.accountID = o.accountID
GROUP BY c.customerID, c.name
HAVING SUM(o.orderAmount) > 5000;

You must subscribe & Login to view more.

Don’t have an account? Register

Or your subscription is under review by admin. Please message on WhatsApp / Telegram.

2 thoughts on “DPDC, Assistant Engineer(ICT), 2025”

Leave a Comment

WhatsApp Telegram Messenger