### 3 AnsBPSC Assistant Programmer Lab Aptitude test Programs and Queries with Proper solution (Taken By BCC) Write Answer Report

Asked by Birds of the sky (2 Golds) Tuesday, 04 Jan 2022, 08:00 AM at (Education Tutorials) Like 0 Save 0

 <<< Previous Dutch Bangla Bank DBBF SSC 2021 batch scholarship notice Apply Online late date 6 February 2022 Log in to Answer Next >>> BPSC aptitude test all programs solutions here

### Date: 31 December 2021BPSC Assistant Programmer 59 posts Lab aptitude test1st Slot Question1.      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 Question1.      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;    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 + a;    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.numberb) SELECT emp_name, salary FROM employees WHERE salary > (SELECT AVG(salary) from employees)Date: 01/01/20221st 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 10Output: 3 4 7 9Solution: #include<stdio.h>int action(int m, int s){    int i;    for(i=0; i<5; i++)    {        if(m[i]==s)            return 0;    }    return 1;}int main(){    int n, 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;    high = n;    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_runFROM players p, innings iWHERE p.address = “Chittagong”Order by Average_run DESC; b) SQL Query on the list of innings number on a specific valueSolution:SELECT count(id) as inningsFROM 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 changeSolution:#include<stdio.h>#include<string.h>int main(){    int l, i;    char s;    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 changeSolution:#include<stdio.h>#include<string.h>int main(){    int l, i;    char s;    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 MBSolution: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) Tuesday, 04 Jan 2022, 08:01 AM

 Upvote 0 Downvote 0 Report 0

### View BPSC All Important Programs here

Answered by Birds of the sky (2 Golds) Tuesday, 04 Jan 2022, 08:19 AM

 Upvote 0 Downvote 0 Report 0

### Previous Aptitude Test Program solution:https://askunion.com/1162Thanks.

Answered by Birds of the sky (2 Golds) Tuesday, 04 Jan 2022, 08:24 AM

 Upvote 0 Downvote 0 Report 0