Loading...
Combined Bank

Post: Assistant Programmer,
Exam Date: 09.02.2024, Exam Taker: BIBM
1. Write a Program to print Prime numbers from 1 to n.
#include <iostream>
using namespace std;
int main() {
    int i, num, n, count;
    cout << "Enter the range: "; 
    cin >> n;
    cout << "The prime numbers in between the range 1 to " << n << " are: ";

    for (num = 1; num <= n; num++) {
        count = 0;
        for (i = 2; i <= num / 2; i++) {
            if (num % i == 0) {
                count++;
                break;
            }
        }
        if (count == 0 && num != 1)
            cout << num << " ";
    }

    return 0;
}
Sample I/O:
Enter the range: 50
The prime numbers in between the range 1 to 50 are: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 

=== Code Execution Successful ===


🔗 Run Online: Prime number between range

2. Write a Program to print Floyd's Triangle for n = 5.
Expected Output:
1
01
101
0101
10101
#include <iostream>
using namespace std;
int main() {
    int i, j, n, p, q;
    cout << "Input number of rows: "; 
    cin >> n;
    for (i = 1; i <= n; i++) {
        if (i % 2 == 0) {
            p = 1;
            q = 0;
        } else {
            p = 0;
            q = 1;
        }
        for (j = 1; j <= i; j++) {
            if (j % 2 == 0)
                cout << p;
            else
                cout << q;
        }
        cout << endl;
    }
    return 0;
}
Sample I/O:
Input number of rows: 6
1
01
101
0101
10101
010101
=== Code Execution Successful ===


🔗 Run Online: Floyd’s Triangle

3. Write a C++ program to find the sum of the series: 1 + 2 + 4 + 7 + 11 + ... + N.
#include <iostream>
using namespace std;
int main() {
    int n, i, sum = 0, term = 1, nextTerm;
    cout << "Enter the value of n: "; 
    cin >> n;
    cout << "The series is: ";
    for (i = 1; i <= n; i++) {
        cout << term << " ";
        sum += term;
        nextTerm = term + i;
        term = nextTerm;
    }

    cout << "\nThe sum of the series is: " << sum << endl;
    return 0;
}
Sample I/O:
Enter the value of n: 10
The series is: 1 2 4 7 11 16 22 29 37 46 
The sum of the series is: 175

=== Code Execution Successful ===


🔗 Run Code: Sum of series: 1+2+4+7+11+…+N

4. What is Polymorphism? Discuss different types of Polymorphism with examples.

Polymorphism means “having many forms.” It allows the same method or function to perform different tasks based on the context. In simpler terms, it enables a single interface to represent different functionalities.

Polymorphism can be broadly categorized into two types:

  1. Compile-time Polymorphism (Static Polymorphism)
  2. Runtime Polymorphism (Dynamic Polymorphism)

1. Compile-time Polymorphism (Static Polymorphism)

Compile-time polymorphism is achieved through method overloading and operator overloading. The method to be executed is determined at compile time based on the method signature.

2. Runtime Polymorphism (Dynamic Polymorphism)

Runtime polymorphism is achieved through method overriding. The method to be executed is determined at runtime based on the object being referred to.


🎥 Video Solution:
Polymorphism & its types.

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.

Leave a Comment

Latest Post
Field Based Job Question & Solution
Bank IT Job Solution

MCQ + Written from Bangladesh Bank, Sonali, Combined Bank IT recruitment.

BPSC IT Job Solution

BPSC Computer/IT cadre & non-cadre post Question papers with full solutions.

Gas Field IT Job Solution

Gas field like TGTDCL, BGDCL, JGTDSL, KGDCL, SGCL, RPGCL, GTCL etc. question solution

Power Sector IT Job Solution

Power sector such as NESCO, DESCO, DPDC, WZPDCL, BPDB, PGCB, BREB etc

Other IT Job Solution

Other Govt. Semi govt. organization like BCC, BTCL, CAAB, NSI etc.

NTRCA IT Job Solution (upcoming)

NTRCA ICT-related posts such as Assistant Teacher, Demonstrator, Lecturer.

IT MCQ Job Solution

Collected MCQ Job solution of BANK, BPSC, POWER SECTOR, GAS Field and Others.

Topic Based Q&S
WhatsApp Telegram Messenger