Ask Question - Get Answer

3 Ans BPSC Assistant Programmer Lab Aptitude test Programs and Queries with Proper solution (Taken By BCC)

Asked by Birds of the sky (2 Golds) Monday, 03 Jan 2022, 09:00 PM at (Education Tutorials)

Please log in to answer, like and save
0
Save 0

<<< Previous
Log in to Answer Next >>>

Answer(s):

Date: 31 December 2021

BPSC Assistant Programmer 59 posts Lab aptitude test

1st Slot Question

1.      Write a C/C++ program to count digits and alphabets from a given string using a function (25 Marks)

2.      a) Write SQL query to find Minimum and Average salary from a given Employee table. b) Write a SQL Query to find 3rd Highest Salary (25 Marks)

 

Solution: (1st Slot)

 

1.      C program

 

#include<stdio.h>

#include<string.h>

void action(char *s, int l)

{

    int i=0, c=0, n=0;

    for(i=0; i<l; i++)

    {

        if((s[i]>='A' && s[i]<='Z') ||(s[i]>='a' && s[i]<='z'))

        {

            c++;

        }

        if(s[i]>='0' && s[i]<='9')

        {

            n++;

        }

    }

    printf("Character = %d", c);

    printf("nNumber =%d", n);

}

int main()

{

    char s[]="Digital Bangladesh 123";

    int l=strlen(s);

    action(s, l);

    return 0;

}

 

2.      a) SELECT MIN(salary), MAX(salary)  FROM employee WHERE age>32

 

             b) SELECT MAX(salary) FROM employee WHERE salary < (SELECT MAX(salary) FROM employee WHERE salary NOT IN (SELECT MAX(salary) FROM employee));

 

 

2nd Slot Question

1.      Write a C/C++ program that takes input 5 numbers in an Array and make sum the biggest and lowest number and check that sum is prime or not prime. (25 Marks)

2.      a) Write a SQL query to delete Duplicate rows from a given table. b) Write a SQL Query to retrieve the Employee name whose salary is greater than average salary (25 Marks)

 

Solution: (2nd Slot)

 

1.      C program Code:

 

#include<stdio.h>

#include<string.h>

int isPrime(int n)

{

    if(n == 0 || n == 1)

        return 0;

    int i;

    for(i=2; i<n; i++)

    {

        if(n%i==0)

            return 0;

    }

    return 1;

}

int main()

{

    int i, j, temp;

    int a[5];

    for(i=0; i<5; i++)

    {

        scanf("%d", &a[i]);

    }

    for(i=0; i<5; i++)

    {

        for(j=0; j<5-i-1; j++)

        {

            if(a[j]>a[j+1])

            {

                temp=a[j];

                a[j]=a[j+1];

                a[j+1]=temp;

            }

        }

    }

    for(i=0; i<5; i++)

    {

        printf("%d ", a[i]);

    }

 

    int num = a[0] + a[4];

    if(isPrime(num) == 1)

    {

        printf("Prime");

    }

    else

        printf("Not Prime");

    return 0;

}

 

 

2.      a) DELETE t1 from test t1 JOIN test t2 WHERE t1.id < t2.id AND t1.number = t2.number

 

b) SELECT emp_name, salary FROM employees WHERE salary > (SELECT AVG(salary) from employees)

 

 

 

 

 

 

Date: 01/01/2022

 

1st Slot Question with Solution:

 

1.      An Array of 5 numbers has given. Print the numbers between the lowest and highest number of this array which are not exists in this array.

Input: 8 2 5 6 10

Output: 3 4 7 9

 

Solution:

 

#include<stdio.h>

int action(int m[5], int s)

{

    int i;

    for(i=0; i<5; i++)

    {

        if(m[i]==s)

            return 0;

    }

    return 1;

}

 

int main()

{

    int n[5], temp, i, j, low, high, m=5;

    for(i=0; i<5; i++)

    {

        scanf("%d", &n[i]);

    }

 

    for(i=0; i<5; i++)

    {

        for(j=0; j<5-i-1; j++)

        {

            if(n[j]>n[j+1])

            {

                temp=n[j];

                n[j]=n[j+1];

                n[j+1]=temp;

            }

        }

    }

    low = n[0];

    high = n[4];

    for(i=low+1; i<high; i++)

    {

        if(action(n, i)==1)

        {

            printf("%d ", i);

        }

    }

 

    return 0;

}

 

2.

a) SQL Query for average run of player which home is Chittagong and show the result in average run descending order.

 

Solution:

SELECT i.AVG(run) as Average_run

FROM players p, innings i

WHERE p.address = “Chittagong”

Order by Average_run DESC;

 

b) SQL Query on the list of innings number on a specific value

 

Solution:

SELECT count(id) as innings

FROM innings

GROUP BY venue;

 

 

2nd Slot Question with Solution:

 

1.       

 

i)                    From a given string change small case vowel to capital case. If vowel already in capital case then no change

 

Solution:

 

#include<stdio.h>

#include<string.h>

int main()

{

    int l, i;

    char s[100];

    gets(s);

    l = strlen(s);

    for(i=0; i<l; i++)

    {

        if(s[i]=='a' || s[i]=='e' || s[i]=='i' || s[i]=='o' || s[i]=='u')

            s[i] = s[i] - 32;

    }

    puts(s);

    return 0;

}

 

 

ii)                  Capital consonant to small case, if consonant already in small case then no change

 

Solution:

 

#include<stdio.h>

#include<string.h>

int main()

{

    int l, i;

    char s[100];

    gets(s);

    l = strlen(s);

    for(i=0; i<l; i++)

    {

        if(s[i]!='a' && s[i]!='e' && s[i]!='i' && s[i]!='o' && s[i]!='u' && s[i]!='A' && s[i]!='E' && s[i]!='I' && s[i]!='O' && s[i]!='U')

        {

            if(s[i]>='A' && s[i]<='Z')

                s[i] = s[i] + 32;

        }

    }

    puts(s);

    return 0;

}

 

 

2.      a. count vaccinator who gave vaccine multiple days. (vaccinator can also give multiple vaccines on the same days)

 

Solution:


Select count(*) from (select count(distinct(date)) as vcc from vaccine_table group by vaccinator_ID  having vcc > 1) as t


(This Question can not be collected properly, especially needed the table columns)

 

 

b. Show database size in MB

 

Solution:

 

SELECT table_schema AS "Database",

ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)"

 FROM information_schema.TABLES

GROUP BY table_schema;

 

 

Compiled By Mamun (www.facebook.com/mamuncse2015 )

Answered by Birds of the sky (2 Golds) Monday, 03 Jan 2022, 09:01 PM

Please log in to Upvote, Downvote and Report

View BPSC All Important Programs here

Answered by Birds of the sky (2 Golds) Monday, 03 Jan 2022, 09:19 PM

Please log in to Upvote, Downvote and Report

Previous Aptitude Test Program solution:

https://askunion.com/1162

Thanks. 

Answered by Birds of the sky (2 Golds) Monday, 03 Jan 2022, 09:24 PM

Please log in to Upvote, Downvote and Report
           

Related Q/A:

1 Ans A C Program to split a number into digits

1 Ans 41st BCS Technical Subjective Written Exam Question Download

3 Ans BPSC Assistant Programmer Lab Aptitude test Programs and Queries with Proper solution (Taken By BCC)

1 Ans Write a C program to print Floyd Triangle

2 Ans BPSC Programming Aptitude Lab Test Important programs

1 Ans The general rules for constructing names for variables (unique identifiers)

1 Ans Bank Exam all important Writing Materials

1 Ans Write a C program to find nth Fibonacci number

1 Ans Which is the best and easy C programming learning website ?

1 Ans Write a C program to implement x power n using recursion


AL MaMun (active on Monday, 06 Sep 2021, 11:15 AM) (4 Golds)
Birds of the sky (active on Sunday, 09 Jan 2022, 09:16 AM) (2 Golds)
Tajrimun Elisha (active on Friday, 22 Nov 2019, 08:56 AM) (2 Golds)
Hena Begum (active on Friday, 15 Feb 2019, 11:04 PM) (8 Bronzes)
Ghost (active on Saturday, 05 Jan 2019, 10:37 AM) (1 Silver)
Md Hasan (active on Saturday, 02 Nov 2019, 10:02 AM) (4 Bronzes)
BrandonDug (active on Thursday, 17 Dec 2020, 05:25 AM) ( New Contributor )
APU KUMAR ROY (active on Sunday, 22 Sep 2019, 02:42 AM) (1 Bronze)
Daily Science (active on Friday, 03 Jan 2020, 07:52 PM) ( New Contributor )
MD SAIFUL ISLAM (active on Friday, 24 Jan 2020, 04:13 PM) ( New Contributor )
student (active on Monday, 27 Jul 2020, 07:28 PM) (2 Bronzes)
GoMedii (active on Monday, 21 Dec 2020, 02:28 PM) ( New Contributor )
Shahansha Habib (active on Monday, 21 Oct 2019, 04:09 PM) (2 Bronzes)
Jackson99 (active on Monday, 27 Apr 2020, 02:44 PM) ( New Contributor )
Hazrat (active on Sunday, 26 May 2019, 05:55 AM) (2 Bronzes)
Apu Kumar Roy (active on Thursday, 28 Mar 2019, 07:05 PM) ( New Contributor )
Hr Hannan (active on Tuesday, 11 Dec 2018, 12:28 PM) (2 Bronzes)
Arif Hossain (active on Tuesday, 08 Jan 2019, 11:59 PM) (3 Silvers)
Sowrov (active on Thursday, 14 Feb 2019, 10:48 AM) (7 Bronzes)
Md Mondol (active on Tuesday, 23 Jul 2019, 10:28 PM) (2 Bronzes)
Show All Members

Online Now 1
Today's Unique PageViews 268
Today's Total PageViews 2734
Site's Total PageViews 3073142