Sunteți pe pagina 1din 4

Holiday Home Work XII (Computer Science)

STRUCTURES

Q1. Write a program to store information of 100 employees(eno, ename, salary) and to display information of an employee
depending upon the employee no given.

Q2. Assuming suitable data types, give necessary declarations for an array of 20 voter records, each record of which consists of
four data values viz. id_no , name , address , age.
Make use of above declarations to write a program segment that prints id_no, name for all those voters whose ages exceed
60.

Q3. A linear array if size 50 stores following informations : name of the country . Country’s capital and per capita income of the
country. Write a complete program in C++ to do the following:
(i) To read a country’s name and display capital and per-capita income.
(ii) To read name of the capital city and display country’s name and displays country’s name and per capital income.

Q4. Assume that , the roll number , marks in English , Computers and Math ( out of 100 ) are to be stored in a structure.
Write a function in C++ which accept array of student and it calculates the following:
(i) No. of students passed with distinction.
(ii) Details of top two students
(iii) Number of students failed.

Q5. Assume an array S Containing elements of structure Student is required to be arranged in descending order of Marks. Write
a C++ function to arrange the same with the help of bubble sort. The array and its size is required to be passed as parameters
to the function. Definition of structure Student is as follows :
struct Student
{
int Rollno;
char Name[25];
float Marks;
}
ARRAY
Q1. Write UDF in C++ which accepts an integer array and its size as arguments/ parameters and assign the elements
into a 2 D array of integers in the following format :f the array is 1,2,3,4,5
The resultant 2D array is given below
10000
12000
12300
12340
12345

Q2. Suppose A, B, C are the array of integers having size m, n, m+n respectively .The elements of array A appear in
ascending order, the elements of array B appear in descending order. Write a UDF in C++ to produce third
array C after merging arrays A and B in ascending order. Take the arrays A, B and C as arguments to the
function.

Q3. Write a function in C++ which accepts an integer array and its size as arguments/parameters and exchanges the
values of first half side elements with the second half side elements of the array.
example : if the array is 8,10,1,3,17,90,13,60 then rearrange the array as 17,90,13,60,8,10,1,3

Q4. Write a function in C++ which accepts an integer array and its size as arguments/parameters and exchanges the
values at alternate locations .
example : if the array is 8,10,1,3,17,90,13,60 then rearrange the array as 10,8,3,1,90,17,60,13

Q5. Given two arrays of integers X and Y of sizes m and n respectively . Write a function named MERGE() which
will produce a third array Z , such that the following sequence is followed .
(a) All odd numbers of X from left to right are copied into Z from left to right.
(ii) All even numbers of X from left to right are copied into Z from right to left.
(iii) All odd numbers of Y from left to right are copied into Z from left to right.
(ii) All even numbers of Y from left to right are copied into Z from right to left.

Q6. Write a function in c++ which accepts a 2D array of integers, number of rows and number of columns as arguments and
assign the elements which are divisible by 3 or 5 into a one dimensional array of integers.

12 3 9 14 
24 25 16 31
If the 2D array is  
19 32 45 27
 
11 5 28 18 
The resultant 1D arrays is 12 , 3 , 9 , 24 , 25 , 45 , 9 , 5 , 18

Q7. Write a function in C++ which accepts a 2D array of integers and its size as arguments and displays the elements of middle
row and the elements of middle column. [Assuming the 2D Array to be a square matrix with odd dimension
i.e. 3×3, 5×5, 7×7 etc...]
Example, if the array content is
354
769
218
Output through the function should be :
Middle Row : 7 6 9
Middle Column : 5 6 1

Q8. Write a function in C++ which accepts a integer array and its size as an arguments and prints the output (using nested loops)
in following format :
Example : if the array is having
12459
Then the output should be
1
22
4444
55555
999999999
Boolean Algebra
Q1. (a) State and prove the Distributive law algebraically.
(b) Write the equivalent POS expression of following SOP form
F (x,y,z)= ∑ (0,2,4,6)
(c) Draw the Logical circuit of the following expression with the help of NAND gate only x+yz
(d) Obtain the simplified form of a Boolean expression using K-Map.
F(a,b,c,d)=∑(0,1,2,3,4,7,11,12,14)
Q2. (a) State De Morgan’s Theorems and verify the same using truth table.
(b) Write the equivalent Canonical Product of Sum Expression for the following Sum of Product Expression
F(X, Y, Z) = Σ (0, 2, 4, 5)
(c) Draw the Logical circuit of the following expression with the help of NOR gate only (A+B)(B+C)(A’+B’)
(d) Reduce the following Boolean expression using K-Map :
F(A, B, C, D) = π(5,6,7,8,9,12,13,14,15)
Q3. (a) State Distributive law and verify the same using truth table.
(b) Write the equivalent Canonical Sum of Product expression for the following Product of Sum Expression
F(X,Y,Z) = π (1,3,6,7)
(c) Write the dual of the following Boolean Expression (A+B)(B+C)(A’+B’).
(d) Reduce the following Boolean expression using K-Map
F(U,V,W,Z) = Σ (0, 1, 2, 3, 4, 10, 11)
SQL
Q.1 Give the following EMPLOYEE realtion, answer the questions:
TABLE : EMP
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SUNITA SHARMA CLERK 7902 1990-12-17 12800 NULL 20
7499 ASHOK SINGHAL SALESMAN 7698 1991-02-20 13600 1300 30
7521 SUMIT AVASTHI SALESMAN 7698 1991-02-22 15250 1500 30
7566 JYOTI LAMBA MANAGER 7839 1991-04-02 14975 NULL 20
7654 MARTIN S. SALESMAN 7698 1991-02-28 16250 2400 30
7698 BINOD GOEL MANAGER 7839 1991-0501 15850 NULL 30
7782 CHETAN GUPTA MANAGER 7839 1991-06-09 12450 NULL 10
7788 SUDHIR RAWAT ANALYST 7566 1991-04-19 15000 NULL 20
7839 KAVITA SHARMA PRESIDENT NULL 1990-01-10 20000 NULL 10
7844 TUSHAR TIWARI SALESMAN 7698 1991-09-08 14500 0 30
7876 ANANAD RATHI CLERK 7788 1997-05-23 16100 NULL 20
7900 JAGDEEP RANA CLERK 7698 1992-03-24 14950 NULL 30
7902 SUMIT VATS ANALYST 7566 1992-10-18 13500 3600 20
7934 MANOJ KAUSHIK CLERK 7782 1990-06-10 15300 NULL 10
Table- Department
DEPTNO DNAME LOC
10 ACCOUNTING DELHI
20 RESEARCH KOLKATA
30 SALES MUMBI
40 OPERATIONS BANGALORE

1. Display all the records (all columns) from table Emp.


2. Display EmpNo and EName of all employees from table Emp.
3. Display Ename, Sal and Sal added with Comm from table Emp.
4. Display EName joined with Job with heading “Employee”, Sal*12 as “Total Salary” from table Emp.
5. Display distinct Sal of employees from table Emp..
6. Show the Structure of table Dept
7. Write a query to display EName and Sal of Employees whose salary is greater than or equal to 3000
from table Emp.
8. Write a Query to display employee name, salary and department number who are not getting commission
from table Emp.
9. Write a Query to display employee Number, name, sal and sal*12 as Annual Salary whose commission is
not NULL from table Emp.
10. Write a Query to display employee name and salary of those employee who don’t have there salary in
the range of 1500 to 2000
11. Write a Query to display name, job, salary, and HireDate of employees who are hired between
February 20, 1981, and May 1, 1981. Order the query in ascending order of HireDate.
12. Write a Query to display the name and hire date of all employees who were hired before 1982.
13. Write a Query to display the name, job , title and salary of employee who do not have manager.
14. Write a Query to display the name of employee whose name contains ‘A’ as third alphabet.
15. Write a Query to display employee number, name, salary, salary increase by 15% expressed as a
whole number. Label the column as New Salary.
16. Write a Query to to display the employee name and commission amount. If the employee does not
earn commission, put “No Commission”.
17. Write a query to display the EName and DeptNo and DName for all employees using tables Emp and
Dept.
18. Write a Query to display employee name, department name and location of all employees who have
manager number between 7500 and 7900.
19. Write a Query to display the employee name, department number and all the employees that worked
in the same department as a given employee.
20. Write a Query to display employee name and HireDate of employees who are employed after
Employee ‘BLAKE’.
21. Write a Query to display employee number, name and manager’s name with their manager number.
22. Write a Query to Display the Sum, Average, Highest and Lowest salary of the employees.
23. Write a Query to Display the Sum, Average, Highest and Lowest salary of the employees grouped by
department number.
24. Write a query to display the number of employee with same job.
25. Write a query to display the average of Highest and lowest salary of each department.
26. Write a query to display the difference of Highest and lowest salary of each department having
maximum salary > 4000.
27. Write a query to display the employee name and job for all employee in the same department as
‘ALLEN’·
28. Write a query to display employee name and salary of those who either work in department 10 or
have salary greater than employee 7521.
29. Write the output of the following :
(i) SELECT ENAME , 12*SAL+COMM FROM EMP WHERE ENAME= ‘Ashok Singhal’;
(ii) SELECT ENAME FROM EMP WHERE ENAME LIKE ‘_ a%’;
(iii) SELECT COUNT(*) FROM EMP WHERE DEPTNO=20;
(iv)SELECT COUNT(COMM) FROM EMP WHERE DEPTNO=20;
(v)SELECT ENAME FROM EMP WHERE MGR IS NULL;
(vi) SELECT COUNT(DISTINCT JOB) FROM EMP;

S-ar putea să vă placă și