Sunteți pe pagina 1din 29

LIST OF PRACTICAL QUESTIONS FOR CLASS XII 1.

Define a class named Cricket in C++ with the following descriptions : private members Target_scope int Overs_bowled int Extra_time int Penalty int cal_penalty() a member function to calculate penalty as follows : if Extra_time <=10 , penalty =1 if Extra_time >10 but <=20, penalty =2 otherwise, penalty =5 public members a function extradata() to allow user to enter values for target_score,overs_bowled,extra_time and call cal_penalty(). a function dispdata() to follow user to view the contents of all data members. 2. Define a class named Directory in C++ with the following descriptions : private members docunames string (documents name in directory) freespace long (total number of bytes available in directory ) occupied long (total number of bytes available in directory) public members newdocuentry() a function to accept values of docunames,freespace & occupied from user retfreespace() a function that return the value of total kilobytes available. (1 KB=1024 b) showfiles() a function that displays the names of all the documents in directory. 3. Define a class named Publisher in C++ with the following descriptions : private members Id long title 40 char author 40 char price , stockqty double stockvalue double valcal() A function to find price*stockqty with double as return type Public members a constructor function to initialize price , stockqty and stockvalue as 0 Enter() function to input the idnumber , title and author Takestock() function to increment stockqty by N(where N is passed as argument to this function) and call the function valcal() to update the stockvalue(). sale() function to decrease the stockqty by N (where N is sale quantity passed to this function as argument) and also call the function valcal() to update the stockvalue outdata() function to display all the data members on the screen.

4. Define a class named Serial in C++ with the following descriptions : private members serialcode int title 20 char duration float noofepisodes integer Public members a constructor function to initialize duration as 30 and noofepisodes as 10. Newserial() function to accept values for serialcode and title. otherentries() function to assign the values of duration and noofepisodes with the help of corresponding values passed as parameters to this function. dispdata() function to display all the data members on the screen. 5. Define a class Competition in C++ with the following descriptions: Data Members Event_no integer Description char(30) Score integer qualified char Member functions A constructor to assign initial values Event_No number as 101,Description as State level Score is 50 , qualified N. Input() To take the input for event_no,description and score. Award(int) To award qualified as Y, if score is more than the cutoffscore passed as argument to the function else N. Show() To display all the details. Q6 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 : if the array is 1,2,3,4,5 The resultant 2D array is given below 10000 12000 12300 12340 12345 Q7 Write UDF in C++ to print the row sum and column sum of a matrix A[2][5] . Q8 Write UDF in C++ to find a name from a list of names using binary search method. Q9. Write UDF in C++ to insert an element in a one-dimensional sorted array in such a way that after insertion the array remains sorted. Q10. Write UDF in C++ to sort an array in ascending order using bubble sort.

Q11. Write UDF in C++ to sort an array (storing names) in ascending order using insertion sort. Q12.Write UDF in C++ to sort an array of structures on the basis of admno, in ascending order using Selection sort. struct student { int admno; char name[20]; }; Q13. 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 argument to the function. Q14.Write a function findsort(),to find whether the given integer Array arr[10] is sorted in ascending order or descending order or is not in order. The function should return A for ascending , D for descending and N for no order. Q15.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 Q16.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 Q17. Write a function in C++ which accepts an integer array and its size as arguments/parameters and reverse the contents of the array without using any second array. Q18.Write a function in C++ which accepts an integer and a double value as arguments/parameters. The function should return a value of type double and it should perform sum of the following series : x-x2/3! + x3/5! x4/7! + x5/9! upto n terms Q19. Assume an array E containing elements of structure employee is required to be arranged in descending order of salary. 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 Employee is as follows : struct employee { int Eno; char name[25]; float salary; }; Q20.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.

Q21. class stack { int data[10]; int top; public: Stack( ) { top=-1;} void push ( ); // to push an element into the stack void pop ( ) ; // to pop an element into the stack void display( );// to display all the elements from the stack }; complete the class with all function definition. Q22. Write a function in C++ to perform a DELETE, insert & Display operation in a dynamically allocated queue considering the following description: struct Node { float U,V; Node *Link; }; class QUEUE { Node *Rear, *Front; public: QUEUE( ) { Rear =NULL; Front= NULL;} Void INSERT ( ); Void DELETE ( ); ~QUEUE ( ); } Q23. Write a function in C++ to perform a PUSH , pop & Display operation in a dynamically allocated stack considering the following : Struct Node { int X,Y; Node *Link; }; class STACK { Node * Top; public: STACK( ) { TOP=NULL;} void PUSH( ); void Pop( ); ~STACK( ); }; Q24. Define function stackpush( ) to insert and stackpop( ) to delete and display, for a static circular queue of array a[10]. Q25.Write a function in C++ to read the content from a text file STORY.TXT, count and display the number of alphabets present in it and display the count of lines starting with alphabet A.

Q26. Write a function in C++ to read the content from a text file NOTES. TXT, count and display the number of blank spaces present in it and also count and display the word the appearing in the text. Q27.Assuming the class EMPLOYEE given below, write functions in C++ to perform the following:(i) Write the objects of EMPLOYEE to binary file. (ii) Reads the objects of EMPLOYEE from binary file and display them on screen. class EMPLOYEE { int ENC; char ENAME[0]; public: Void GETIT(){ cin>> ENO;gets(ENAME);} Void SHOWIT() { cout>> ENO<<ENAME;<<endl; } }; Q28. Asuming a binary file FUN.DAT is containing objects belonging to a class LAUGHTER( as defined below). Write a user defined function in C++ to add more objects belonging to class LAUGHTER at the bottom of it. Class LAUGHTER { int idno; char Type[5]; char Desc[255]; PUBLIC: void Newentry(){ cin>> Idno; gets(Type); gets(Desc);} void Showonscreen() { cout<<Idno<< <<Type<<endll<<Desc<<endl;} }; Q29. Assuming that a text file named TEXT1.TEXT already contains some text written into it, write a function named vowelwords(), that reads the file TEXT1.TEXT and creates a new file named TEXT2.TEXT,which shall contain only those words from the file TEXT1.TEXT which does not start with a vowel(i.e, with A,E,I,O,U). FOR example, if the file TEXT1.TXT contains. Carry umbrella and Overcoat when it Rains then the file TEXT2.TXT shall contain Carry when it Rains.

Q32. Given a binary file SPORTS.DAT, containing records of the following structure type: struct sport { char Event[20]; Char Participant[10][30]; }; Write a function in C++ that would read the contents from the file SPORTS.dat and create a file named Atheletic.dat copying only those records from sports.dat where the event name is Atheletics. Q33 class Queue { int data[10]; int front, rear; public: Queue(){front=rear=0;} void insert(); void delet(); void display(); }; Complete the class with all function definitions: Q34 WAF sum() in c++ with two arguments, double X and int n. The function should return a value of type double and it should find the sum of the following series: 1+ X / 2! + X3 / 4! + X5 / 6!+ X7 / 8!+ X9 / 10! ++ X 2n-1 / (2n)! Q35 WAF check() to check if the passed array of 10 integers is sorted or not. The function should return 1 if arranged in ascending order, -1 if arranged in descending order, 0 if it is not sorted. Q36 Given the following class: char *info={ over flow,under flow}; class stack { int top; stk[5]; void err_rep(int errornum){cout<<info[errornum];} //report error message public: void init(){top=0;} void push(int); void pop(); void display(); }; Complete the class with all function definitions:

Q37. Following is the structure of each record in a data file named Laugh.dat struct LAUGHTER { int idno; ` char Type[5]; char Desc[255]; }; Write a function to update the file with a new value of LaughterType. The value of laughter number and laughter type are read during the execution of the program. 38) Write a function in C++ which accepts an integer array and its size as arguments / parameters and then from 1-d array assign the values in 2 d array such that the odd numbers are copied in the first row and even numbers in the second row of a two dimensional array. The unused cells of two dimensional array must be filled with 0. If the array is 1, 2, 3, 4, 5, 6 The resultant 2-D array is given below 135000 000642 39) Write a function to count the number of house number that are starting with 13 from a text file that contains house numbers of all students in a school. The file house.txt contains only house numbers as record. Example : If the file house.txt contains the following records, 10101 10113 13101 13103 The function should display the output as 2. 40) Write a function in c++ to read and display the records of computers that cost more than Rs. 20000 from the binary file COMP.DAT, assuming that the binary file is containing the objects of the following class : class COMPUTER { int srno; char model[25]; float price; public: float Retpr( ) { return price; } void Enter( ){ cin>>srno>>price; gets(model); } void Display( ){ cout<<rno<<Name<<price<<endl;} };

41)Observe the program segment carefully and answer the question that follows:

class student { int student_no; char student_name[20]; int mark; public: void enterDetails( ) { cin>> student_no >> mark ; gets(student_name); } void showDetail( ); int get_mark( ){ return mark;} }; Assuming a binary file RESULT.DAT contains records belonging to student class, write a user defined function to separate the records having mark (i) Greater than 79 into EXCELLENT.DAT file (ii) Greater than 59 but less than 80 into AVERAGE.DAT file. (iii)Remaining records should be in RESULT.DAT file. 42) Define a class NUTRITION in C++ with following description: Private Members: Access number Integer Name of Food String of 25 characters Calories Integer Food type String Cost Float AssignAccess( ) Generates random numbers between 0 to 99 and return it. Public Members A function INTAKE( ) to allow the user to enter the values of Name of Food, Calories, Food type cost and call function AssignAccess() to assign Access number. A function OUTPUT( ) to allow user to view the content of all the data members, if the Food type is fruit. 43) Assume an array A containing elements of structure Teacher is required to be arranged in Descending order of salary. Write a C++ program to arrange the same with the help of selection sort. The array and its size is required to be passed as parameters to the functions. Definition of structure Teacher is as under: struct Teacher { int ID; char Teacher_name[25]; float Salary; }; 44) Define a class Departmental with the following specification : private data members

Prod_name string (45 charactes) Listprice long Dis_Price long [ Discount Price] Net long [Net Price ] Dis_type char(F or N) [ Discount type] Cal_price() The store gives a 10% discount on every product it sells. However at the time of festival season the store gives 7% festival discount after 10% regular discount. The discount type can be checked by tracking the discount type. Where F means festival and N means Non- festival .The Cal_price() will calculate the Discount Price and Net Price on the basis of the following table. Product Name Washing Machine Colour Television Refrigerator OTG CD Player List Price(Rs.) 12000 17000 18000 8000 4500

public members Constructor to initialize the string elements with NULL, numeric elements with 0 and character elements with N Accept() - Ask the store manager to enter Product name, list Price and discount type . The function will invoke Cal_price() to calculate Discount Price and Net Price . ShowBill() - To generate the bill to the customer with all the details of his/her purchase along with the bill amount including discount price and net price. 45)Write a function in c++ to count the number of capital vowels present in a text file FILE.TXT. 46)Define a class PhoneBill in C++ with the following descriptions. Private members: CustomerName of type character array PhoneNumber of type long No_of_units of type int Rent of type int Amount of type float. calculate( ) This member function should calculate the value of amount as Rent+ cost for the units.Where cost for the units can be calculated according to the following conditions. No_of_units Cost First 50 calls Free Next 100 calls 0.80 @ unit Next 200 calls 1.00 @ unit Remaining calls 1.20 @ unit Public members: * A constructor to assign initial values of CustomerName as Raju, PhoneNumber as

259461, No_of_units as 50, Rent as 100, Amount as 100. * A function accept ( ) which allows user to enter CustomerName, PhoneNumber, No_of_units And Rent and should call function calculate ( ). * A function Display ( ) to display the values of all the data members on the screen. 47) Write a function in C++ which accepts an integer array and its size as arguments/parameters and assign the elements into a two dimensional array of integers in the following format (size must be odd) If the array is 1 2 3 4 5 or If the array is 10 15 20 The output must be the output must be 10005 02040 00300 02040 10005 10 0 20 0 15 0 10 0 20

48) Write a function RevText() to read a text file Input.txt and Print only word in reverse order . Example: If value in text file is: INDIA IS MY COUNTRY Output will be: AIDNI SI MY COUNTRY 49) Given the binary file ITEM.DAT, containing the records of the following structure: class item { int item_no; char item_name[20]; int stock; public: int itmreturn() { return item_no; } }; Implement the function DelStock(), which delete a record of matching item_no entered through the keyboard. 50) Write a function in C++ to count and display the no of lines starting with the vowel A having single character in the file Vowel.TXT. Example: If the Line contains: A boy is playing there. I love to eat pizza.

A plane is in the sky. Then the output should be: 2 (51) Write a function in c++ to read and display the records of computers that cost more than Rs. 20000 from the binary file COMP.DAT, assuming that the binary file is containing the objects of the following class : class COMPUTER { int srno; char model[25]; float price; public: float Retpr( ) { return price; } void Enter( ){ cin>>srno>>price; gets(model); } void Display( ){ cout<<rno<<Name<<price<<endl;} }; 52)Consider the following portion of a program, which implements passengers Queue for a train. Complete all the definition, to insert a new node, delete and display in the queue with required information: struct NODE { long TicketNo; char PName[20]; // Passenger Name NODE *NEXT; } class TrainQueue { NODE *rear, *front; public: TrainQueue( ) { rear = NULL, front = NULL ;} void Q_Insert( ); void Q_Delete ( ); void Q_Display ( ); ~TrainQueue( ); }; 53) 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 the middle column. 54)Write function definition for Non_Diagonal() in C++ to display all the elements other than the 3 diagonal(left and right) of a two dimensional integer array Q of size 4 x 4 passed as a parameter to the function. Example: If the two dimensional array contains

The function call should display

55)Define a class named PRODUCT in C++ with following description: Private Members: P_NO // Product number P_Type // Product Type P_Name // Product Name P_Price // Product Price A function Get_Prod ( ) to set the price of the product according to the following: For the value of P_Type Mobile P_Name P_Price SONY 15000 SAMSUNG 13000 For P_Type other than Mobile P_Price gets included 14% Extra charge for installation.

Public Members: A constructor to assign initial values of P_NO, P_Type and P_Name as NOT ASSIGNED and P_Price as 0. A function Get_Info( ) to input the values of P_NO, P_Name and P_Type and also invoke Get_Prod( ) function. A function Disp_Info( ) to display the value of all the data members. 56) Define a class Society with the following specifications. Private Members : society_name char (30) house_no integer no_of_members integer flat char(10) income float Public members: A constructer to assign initial values of society_name as Mahavir Nagar, flat as A Type, house_no as 56, no_of_members as 6, income as 50000. input( ) to read data members. alloc_flat( ) To allocate flat according to income income >=50000 Flat A Type income >=25000 and income <50000 Flat B Type income <25000 Flat C Type show( ) to display all details. (57) Write function definition for Total( ) in C++ to display the total number of word school present in a text file FUNCTION.TXT. Example:

If the content of the file FUNCTION.TXT is as follows: The school function is taking place in December. Our school has participated in many inter- school events. The school life is the best. The function Total() should display the following: Total number of word school:4 58) Define a class Movie in C++ with following description: Private Members Mcode //Data member for Movie code Type //Data member for the type of Movie Rating //Data member for Movie critic rating Collections //Data member for movie collections per day Assign() //A function to assign Rating a value based on Collections as follows: Collections Rating <=1000000 2** >1000000 && <=5500000 3*** >5500000 4**** Public Members Read() //A function to enter value of Mcode,Type and Collections . It will invoke Assign() function. Display() //A function to display Mcode,Type,Rating and Collections Ret_Rating() //A function to return value of Rating (59)Write function definition for Sales( ) in C++ to read and display the details of the regions having a sale of 20000 or more from a binary file COMPANY.DAT which contains objects of the following class. class Company { int Id; //Region id char C_Name[20]; //Company Name char Region[30]; //Region(South,North,East, West) float Sales; //total sales public: void Accept_Val(); //Function to enter the details void Show_Val(); //Function to display the details float RSales(){return Sales;} }; 60) WAF which is passed a character pointer and that function should reverse the string.

(1) Study the following tables STAFF and SALARY and write SQL commands for the question (i) to (iv) and give output for SQL queries (v) to (vi) Relation : STAFF ID 10 1 10 4 10 7 11 4 10 9 10 5 11 7 11 1 13 0 18 7 ID 10 1 10 4 10 7 11 4 10 9 10 5 11 7 11 1 13 NAME DOJ DEPT Sales Finance SEX QUALF M M M F F M F M M F MBA CA MTECH MBA ICWA BTECH MTECH CA MBA BTECH

Siddharth 12/01/02 Raghav Naman Nupur Janvi Rama Jace Binoy Samuel Ragini 8/05/88

14/05/88 Research 1/02/03 18/7/04 14/4/07 27/6/87 12/1/90 7/3/99 Sales Finance Research Sales Finance Sales

12/12/02 Research

relation : SALARY BASIC ALLOWANCE COMM_PERC 15240 23000 14870 21000 24500 17000 12450 13541 25000 5400 1452 2451 3451 1452 1250 1400 3652 4785 3 4 3 14 10 2 3 9 15

0 18 7 i) ii) iii)

14823

5862

Display the name of all CAs who are working for more than 5 years Display the number of staff joined year-wise Hike the Allowance of all female staff working in finance sector and joined the company before 2000 iv) Display the average salary given to the employee in each department v) SELECT DEPT, COUNT(*) FROM STAFF WHERE SEX=m GROUP BY DEPT HAVING COUNT(*) >2; vi) SELECT AVG(BASIC+ ALLOWANCE), QUALF FROM SALARY S1, STAFF S2 WHERE S1.ID=S2.ID GROUP(QUALF) ; vii) SELECT DISTINCT QUALF FROM STAFF; viii) SELECT NAME, BASIC+ALLOWANCE FROM STAFF S, SALARY SA 2) Consider the following tables SCHOOL and ADMIN. Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v) to (viii). SCHOOL CODE 1001 1009 1203 1045 1123 1167 1215 TEACHERNAME RAVI SHANKAR PRIYA RAI LISA ANAND YASHRAJ GANAN HARISH B UMESH SUBJECT ENGLISH PHYSICS ENGLISH MATHS PHYSICS CHEMISTRY PHYSICS DOJ 12/03/2000 03/09/1998 09/04/2000 24/08/2000 16/07/1999 19/10/1999 11/05/1998 PERIOD S 24 26 27 24 28 27 22 EXPERIENC E 10 12 5 15 3 5 16

ADMIN CODE GENDER 1001 MALE 1009 FEMALE 1203 FEMALE 1045 MALE 1123 MALE 1167 MALE 1215 MALE

DESIGNATION VICE PRINCIPAL COORDINATOR COORDINATOR HOD SENIOR TEACHER SENIOR TEACHER HOD

i) To display TEACHERNAME, PERIODS of all teachers whose periods less than 25.

ii) To display TEACHERNAME, CODE and DESIGNATION from tables SCHOOL and ADMIN whose gender is male. iii) To display the TEACHERNAME subject wise. iv) To display CODE, TEACHERNAME and SUBJECT of all teachers who have joined the school after 01/01/1999. v) SELECT MAX (EXPERIENCE), SUBJECT FROM SCHOOL GROUP BY SUBJECT; vi) SELECT TEACHERNAME, GENDER FROM SCHOOL, ADMIN WHERE DESIGNATION = COORDINATOR AND SCHOOL.CODE=ADMIN.CODE; vii) SELECT DESIGNATION, COUNT (*) FROM ADMIN GROUP BY DESIGNATION HAVING COUNT (*) <3; viii) SELECT COUNT (DISTINCT SUBJECT) FROM SCHOOL;

(3)Consider the following table FLIGHT and FARES. Write the SQL commands for the statements (i) to (iv) and output from (v) to (viii). Table: FLIGHT FL_NO DEPARTURE IC301 MUMBAI IC799 BANGALORE MC101 INDORE IC302 DELHI AM812 KANPUR IC899 MUMBAI AM501 DELHI MU499 MUMBAI IC701 DELHI Table: FARE FL_NO 1C701 MU499 AM501 IC899 1C302 1C799 MC101 (i) (ii) AIRLINES Indian Airlines Sahara Jet Airways Indian Airlines Indian Airlines Indian Airlines Deccan Airlines ARRIVAL NO_FLIGHTS NOOFSTOPS DELHI 8 0 DELHI 2 1 MUMBAI 3 0 MUMBAI 8 0 BANGALORE 3 1 KOCHI 1 4 TRIVANDRUM 1 5 MADRAS 3 3 AHMEDABAD 4 0 FARE 6500 9400 13450 8300 4300 10500 3500 TAX% 10 5 8 4 9 10 4

Display Flight No, No of Flights arriving to the DELHI Display all the airlines that have maximum no of flights.

(iii) Display total fare of all the airlines. (iv) To display departure and arrival points of flight no 1C302 and MU499. Give the Output: (v) SELECT COUNT(DISTINCT FL_NO) FROM FLIGHT; (vi) SELECT MIN(NOOFSTOPS) FROM FLIGHT WHERE FL_NO = IC899; (vii) SELECT AVG(FARE) FROM FARE WHRE AIRLINES = Indian Airlines; (viii) SELECT FL_NO, NO_FLIGHTS FORM FLIGHT WHERE DEPARTURE=MUMBAI;

4) Consider the following tables CUSTOMER and MOBILE. Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v) to (viii)

(i) To display the records of those customer who take the connection of Bsnl and Airtel

in ascending order of Activation date. (ii) To decrease the amount of all customers of Reliance connection by 500. (iii) Count the no. of companies giving connection from CUSTOMER table whose name starts with P. (iv) To display the ID and Cname from table Customer and Make from table Mobile, with their corresponding matching ID. (v) select Cname , Make form Customer, Mobile where Customer.ID = Mobile.ID; (vi) select Connection , sum(Amount) from Customer group by Connection ; (vii) SELECT COUNT(DISTINCT Make) FROM Mobile; . (viii) SELECT AVG(Amount) FROM Customer where Validity >= 180;

5) Consider the following tables ARTIST and GALLERY. Write SQL commands for the statements (C1) 6 to (C4) and give outputs for SQL queries (D1) to (D4)

1. To display A_NAME(Artist Name) and TITLE of all Modern type paintings from table ARTIST 2. To display the details of all the Artists in descending order of TITLE within TYPE from table

3. To display the A_NAME, G_NAME and Date of Display (D_OF_DISPLAY) for all the Artists who are having a display at the gallery from the tables ARTIST and GALLERY. 4. To display the highest price of paintings in each type from table ARTIST 5. SELECT A_NAME, TITLE, PRICE FROM ARTIST WHERE PRICE BETWEEN 120000 AND 300000; 6. SELECT DISTINCT TYPE FROM ARTIST ; 7. SELECT MAX(FEES),MIN(D_OF_DISPLAY) FROM GALLERY; 8. SELECT COUNT(*)FROM ARTIST WHERE PRICE<300000;

6) TABLE : GRADUATE S.NO 1 2 3 4 5 6 7 8 9 10 (a) NAME KARAN DIWAKAR DIVYA REKHA ARJUN SABINA JOHN ROBERT RUBINA VIKAS STIPEND 400 450 300 350 500 400 250 450 500 400 SUBJECT PHYSICS COMP. Sc. CHEMISTRY PHYSICS MATHS CEHMISTRY PHYSICS MATHS COMP. Sc. MATHS AVERAGE 68 68 62 63 70 55 64 68 62 57 DIV. I I I I I II I I I II

List the names of those students who have obtained DIV 1 sorted by NAME. (b) Display a report, listing NAME, STIPEND, SUBJECT and amount of stipend received in a year assuming that the STIPEND is paid every month. (c) To count the number of students who are either PHYSICS or COMPUTER SC graduates.

(d) (e)

To insert a new row in the GRADUATE table: 11,KAJOL, 300, computer sc, 75, 1 Give the output of following sql statement based on table GRADUATE: (i) Select MIN(AVERAGE) from GRADUATE where SUBJECT=PHYSICS; (ii) Select SUM(STIPEND) from GRADUATE WHERE div=2; (iii) Select AVG(STIPEND) from GRADUATE where AVERAGE>=65; (iv) Select COUNT(distinct SUBDJECT) from GRADUATE; Assume that there is one more table GUIDE in the database as shown below: Table: GUIDE MAINAREA PHYSICS COMPUTER SC CHEMISTRY MATHEMATICS ADVISOR VINOD ALOK RAJAN MAHESH

(f)

g) What will be the output of the following query: SELECT NAME, ADVISOR MAINAREA; FROM GRADUATE,GUIDE WHERE SUBJECT=

Q7. Empid 010 105 152 215 244 300 335 400 441 Employees Firstname Lastname Ravi Kumar Harry Waltor Sam Tones Sarah Ackerman Manila Sengupta Robert Ritu Rachel Peter Samuel Tondon Lee Thompson EmpSalary Address Raj nagar Gandhi nagar 33 Elm St. 440 U.S. 110 24 Friends street 9 Fifth Cross Shastri Nagar 121 Harrison St. 11 Red Road City GZB GZB Paris Upton New Delhi Washington GZB New York Paris

Empid 010 105 152 215 244 300 335 400 441

Salary 75000 65000 80000 75000 50000 45000 40000 32000 28000

Benefits 15000 15000 25000 12500 12000 10000 10000 7500 7500

Designation Manager Manager Director Manager Clerk Clerk Clerk Salesman salesman

Write the SQL commands for the following : (i) To show firstname,lastname,address and city of all employees living in paris (ii) (iii) (iv) (i) To display the content of Employees table in descending order of Firstname. To display the firstname,lastname and total salary of all managers from the tables Employee and empsalary , where total salary is calculated as salary+benefits. To display the maximum salary among managers and clerks from the table Empsalary.

Give the Output of following SQL commands: Select firstname,salary from employees ,empsalary where designation = Salesman and Employees.empid=Empsalary.empid; (ii) Select count(distinct designation) from empsalary; (iii) Select designation, sum(salary) from empsalary group by designation having count(*) >2; (iv) Select sum(benefits) from empsalary where designation =Clerk;

Q8 . Write the SQL commands for the following on the basis of tables INTERIORS and NEWONES Table: INTERORS SNO ITEMNAME TYPE DATEOFSTOC PRIC DISCOUNT K E 1 Red Rose Double Bed 23/02/02 32000 15 2 Soft Touch Baby Cot 20/1//02 9000 10 3 Jerrys Home Baby Cot 19/02/02 8500 10 4 Rough Wood Office Table 01/01/02 20000 20 5 Comfort Zone Double Bed 12/01/02 15000 20 6 Jerry Look Baby Cot 24/02/02 7000 19 7 Lion King Office Table 20/02/02 16000 20 8 Royal Tiger Sofa 22/02/02 30000 25 9 Park Sitting Sofa 13/12/01 9000 15 10 Dine Paradise Dining Table 19/02/02 11000 15 Table: NEWONES SN ITEMNAME TYPE DATEOFSTO PRIC DISCOUN

O 11 12 13 (i) (ii)

White Wood James 007 Tom Look

CK Double Bed 23/02/02 Sofa 20/02/03 Baby Cot 21/02/03

E T 20000 15000 7000

20 15 10

To list the ITEMNAME which are priced at more than 1000 from the INTERIORS table To list ITEMNAME and TYPE of those items, in which DATEOFSTOCK is before 22/01/02 from the INTERIORS table in descending order of ITEMNAME To show all information about the sofas from the INTERIORS table To display ITEMNAME and DATEOF STOCK of those items in which the discount percentage is more than 15 from INTERIORS table To count the number of items, whose type is Double Bed from INTERIORS table

(iii) (iv) (v)

(vi) To insert a new row in the NEWONES table with the following data 14,True Indian, Office Table, 28/03/03,15000,20 (vii) Get the Output (Use the above table without inserting the record) a) Select COUNT(distinct TYPE) from INTERIORS b) Select AVE(DISCOUNT) from INTERIORS where TYPE=Baby Cot c) Select SUM(Price) from INTERIORS where DATEOF STOCK<{12/02/02} d) Select MAX(Price) from INTERIORS , NEWONES;

9.Consider the following tables BOOKS and ISSUED. Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v) to (viii) BOOKS Book_Id C01 F01 T01 T02 F02 ISSUED Book_Id T01 C01 Quantity_Issue d 4 5 Book_Name Author_Name Fast Cook Lata Kapoor The Tears My C++ C++ Brain Thuderbolts William Hopkins Brain & Brooke A.W.Rossaine Anna Roberts Publishers Price EPB 355 First FPB TDH First 650 350 350 750 Type Cooker y Fiction Text Text Fiction Quantity 5 20 10 15 50

F01 C01 T02

2 6 3

1. To list the names from books of Text type. 2. To display the names and price from books in ascending order of their price. 3. To increase the price of all books of EPB publishers by 50. 4. To display the Book Name, Quantity_Issued and Price for all books of EPB publishers. 5. Select max(price) from books; 6. Select count(DISTINCT Publishers) from books where Price >=400; 7. Select Book_Name, Author_Name from books where Publishers = First; 8. Select min(Price) from books where type = Text;

10. Consider the following tables FACULTY and COURSES. Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v) to (viii)

(i) To display details of those Faculties whose date of joining is before 31-12-2001. (ii) To display the details of courses whose fees is in the range of 15000 to 50000 (both values included). (iii) To increase the fees of Dreamweaver course by 500. (iv) To display F_ID, Fname, Cname of those faculties who charged more than15000 as fees. (v) Select COUNT(DISTINCT F_ID) from COURSES; (vi) Select MIN(Salary) from FACULTY,COURSES where COURSES.F_ID = FACULTY.F_ID; (vii) Select SUM(Fees) from courses Group By F_ID having count(*) > 1; (viii) Select Fname, Lname from FACULTY Where Lname like M%;

11.

(i) To display the name of all Games with their Gcodes (ii) To display details of those games which are having PrizeMoney more than 7000. (iii) To display the content of the GAMES table in ascending order of ScheduleDate. (iv) To display sum of PrizeMoney for each of the Number of participation groupings (as shown in column Number 2 or 4) (v) SELECT COUNT(DISTINCT Number) FROM GAMES; (vi) SELECT MAX(ScheduleDate),MIN(ScheduleDate) FROM GAMES; (vii) SELECT SUM(PrizeMoney) FROM GAMES; (viii) SELECT DISTINCT Gcode FROM PLAYER;

Q12.

(i) Display FirstName and City of Employee having salary between 50,000 and 90,000 (ii) Display details of Employees who are from PARIS city. (iii) Increase the benefits of employee having W_ID = 210 by 500. (iv) Count number of employees whose name starts from character S. (v) Select MAX(salary) from desig (vi) Select FirstName from employee, desig where designation = MANAGER AND employee.W_ID = desig.W_ID; (vii) Select COUNT (DISTINCT designation) from desig; (viii) Select designation, SUM(salary) from desig Group by designation Having count (*) > 2;

Q13

Write the SQL commands:(i) To display Firstname, Lastname, Address and City of all employees living in ND from the table EMPLOYEES. (ii) To display the contents of EMPLYEES table in descending order of firstname. (iii) To display the firstname, lastname, and Total Salary of all mangers from the table EMPLOYEES and EMPSALARY. Where total salary is calculate as Salary + Benefits. (iv) To display the maximum salary among Managers and Clerks from EMPSALARY. (v) Write the output of the following:(a) Select COUNT (DISTINCT DESIGNATION) FROM EMPSALARY. (b) Select firstname, salary from EMPLOYEES, EMPSALARY WHERE Designation = Salesman AND EMPLOYEES. Emid = EMPSALARY. Emid. (c) Select designation. Sum (salary) from EMPSALARY Group ByDesignation Having Count (*)>2; (d) Select SUM (Benefits) from EMPLOYEES where designation =clerk;
Consider the following tables Product and Clint. Write SQL commands for the statement (i) to (iv) and give outputs for SQL queries (v) to (viii)

Table: PRODUCT P_ ID TP01 FW05 BS01 SH06 FW12 Table:CLIN T C_ID 01 06 12 15 16

ProductName

Manufac turer Talcum Powder LAK Face Wash ABC Bath Soap ABC Shampoo XYZ Face Wash XYZ

Price 40 45 55 120 95

ClientName Cosmetic Shop Total Health Live Life Pretty Woman Dreams

City Delhi Mumbai Delhi Delhi Banglore

P_ID FW05 BS01 SH06 FW12 TP01

(i) To display the details of those Clients whose City is Delhi. (ii) To display the details of Products Whose Price is in the range of 50 to 100(Both values included). (iii) To display the ClientName, City from table Client, and ProductName and Price from table Product, with their corresponding matching P-ID. (iv) To increase the Price of all Products by 10. (v) SELECT DISTINCT City FROM Client; (vi) SELECT Manufacturer, MAX(Price), Min(Price), Count(*) FROM Product GROUP BY Manufacturer; (vii) SELECT ClientName, ManufacturerName FROM Product, Client WHERE Client.Prod-ID=Product.P_ID; (viii) SELECT ProductName, Price * 4 FROM Product;

Consider the following tables item and Customer. Write SQL Commands for the statement (i) to (iv) and give outputs for SQL queries (v) to (viii). Table: ITEM I_ID PC01 LC05 PC03 PC06 LC03 ItemName Personal Computer Laptop Personal Computer Personal Computer Laptop Manufa cture ABC ABC XYZ COMP PQR Price 35000 55000 32000 37000 57000

Table: CUSTOMER C_ID 01 06 12 15 16

CustomerName MRS REKHA MANSH RAJEEV YAJNESH VIJAY

City Delhi Mumbai Delhi Delhi Banglore

l_ID LC03 PC03 PC06 LC03 PC01

(i) To display the details of those customers whose city is Delhi.

(ii) To display the details of item whose price is in the range of 35000 to 55000 ( both values included) (iii) To display the customer name, city from table Customer, and itemname and price from table Item, with their corresponding matching I_ID. (iv) To increase the price of all items by 1000 in the table Item. (v) SELECT DISTINCT City FROM Customer; (vi) SELECT ItemName, MAX(Price), Count(*) FROM Item GROUP BY ItemName; (vii) SELECT CustomerName, Manufacturer FROM Item, Customer WHERE Item.Item_Id=Customer.Item_Id (viii) SELECT ItemName, Price* 100 FROM Item WHERE Manufacture= ABC;

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