Loading...
Dutch Bangla Bank

Post: MTO Card Operation, Exam Date: 16.02.2024
Exam Taker: BUET; MCQ: 20 Dept:80
1. Write a C Program to generate the Fibonacci series n number of times.

#include <stdio.h>

int main() {
    int n, i;
    int a = 0, b = 1, next;

    printf("Enter number of terms: ");
    scanf("%d", &n);

    printf("Fibonacci Series:\n");

    for(i = 1; i <= n; i++) {
        printf("%d ", a);
        next = a + b;
        a = b;
        b = next;
    }

    return 0;
}
Input:
5
Output:
Fibonacci Series:
0 1 1 2 3
2. Write a program that take input an array with positive and negative number and rearrange this with positive to negative.

#include <stdio.h>

int main() {
    int n, i, pos[100], neg[100];
    int p = 0, ne = 0;

    printf("Enter number of elements: ");
    scanf("%d", &n);

    int arr[100];

    printf("Enter elements:\n");
    for(i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
    }

    // Separate positive and negative numbers
    for(i = 0; i < n; i++) {
        if(arr[i] >= 0)
            pos[p++] = arr[i];
        else
            neg[ne++] = arr[i];
    }

    // Rearrange: positives first, then negatives
    printf("Rearranged array:\n");

    for(i = 0; i < p; i++) {
        printf("%d ", pos[i]);
    }

    for(i = 0; i < ne; i++) {
        printf("%d ", neg[i]);
    }

    return 0;
}
Input:
5
1 -2 3 -4 5
Output:
Rearranged array:
1 3 5 -2 -4
3. Write a program that takes input for date, month, and year, and verifies if the given date is valid. If valid, display "Valid Date", otherwise display "Invalid Date". Also, explain how leap years are handled in your program.
#include <stdio.h>

int isLeapYear(int year) {
    if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
        return 1;
    return 0;
}

int main() {
    int day, month, year;
    int valid = 1;

    printf("Enter day month year: ");
    scanf("%d %d %d", &day, &month, &year);

    // Check month validity
    if (month < 1 || month > 12)
        valid = 0;

    // Days in months
    int daysInMonth[] = {31,28,31,30,31,30,31,31,30,31,30,31};

    // Adjust February for leap year
    if (isLeapYear(year))
        daysInMonth[1] = 29;

    // Check day validity
    if (day < 1 || day > daysInMonth[month - 1])
        valid = 0;

    if (valid)
        printf("Valid Date\n");
    else
        printf("Invalid Date\n");

    return 0;
}

A year is considered a leap year if:
• It is divisible by 4 but not divisible by 100, OR
• It is divisible by 400
In the program, February (month = 2) is assigned 29 days instead of 28 when the year is a leap year.

4. Given an IP address 10.10.250.0/24. Find total number of computer connected in a network and list of network ID
Given: IP address = 10.10.250.0/24Subnet mask: /24 = 255.255.255.0Total number of IP addresses: 232-24 = 28 = 256Total number of computers (usable hosts): 256 – 2 = 254Network ID: 10.10.250.0Broadcast address: 10.10.250.255Usable host range: 10.10.250.1 to 10.10.250.254Total connected computers = 254 Network ID = 10.10.250.0

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