Practical List for Computer Science

advertisement
Practical List
1.
2.
3.
4.
5.
WAP to calculate factorial of a given number n.
WAP to check whether a number is prime or not.
WAP to print Fibonacci series of ‘n’ numbers, where n is given by the programmer.
WAP to check whether a given number is palindrome or not
WAP to do the following:
a. Generate the following menu:
1. Add two numbers.
2. Subtract two numbers.
3. Multiply two numbers.
4. Divide two numbers.
5. Exit.
b. Ask the user to input two integers and then input a choice from the menu. Perform all
the arithmetic operations which have been offered by the menu. Checks for errors
caused due to inappropriate entry by user and output a statement accordingly.
6. WAP to read a set of numbers from keyboard & to find sum of all elements of the given
array using a function.
7. WAP to exchange contents of two variables using call by reference.
8. WAP to display content of an array using pointers
9 Calculate area of different geometrical figures (circle, rectangle,square, triangle) using
function overloading.
10. C++ PROGRAM TO PASS OBJECT AS AN ARGUMEMT. The program Adds the two heights
given in feet and inches.
12. . Define a class TAXPAYER in C++ with following description :
Private members :
 Name of type string
 PanNo of type string
 Taxabincm (Taxable income) of type float
 TotTax of type double
 A function CompTax( ) to calculate tax according to the following slab:
Taxable Income
Tax%
Up to 160000
0
>160000 and <=300000
5
>300000 and <=500000
10
>500000
15
Public members :
 A parameterized constructor to initialize all the members
 A function INTAX( ) to enter data for the tax payer and call function CompTax( )
to assign TotTax.
 A function OUTAX( ) to allow user to view the content of all the data members.
13 Define a class HOTEL in C++ with the following description:
Private Members
 Rno
//Data Member to store Room No
 Name
//Data Member to store customer Name
 Tariff
//Data Member to store per day charge
 NOD
//Data Member to store Number of days

CALC
//A function to calculate and return amount as NOD*Tariff
and if the value of NOD*Tariff is more than 10000 then as
1.05*NOD*Tariff
Public Members:
 Checkin( )
//A function to enter the content RNo,Name, Tariff and
NOD
 Checkout()
//A function to display Rno, Name, Tariff, NOD
and Amount (Amount to be displayed by calling function CALC( )
14. Define a class Applicant in C++ with following description:
Private Members
 A data member ANo ( Admission Number) of type long
 A data member Name of type string
 A data member Agg(Aggregate Marks) of type float
 A data member Grade of type char
 A member function GradeMe( ) to find the Grade as per the Aggregate Marks obtained
by a student. Equivalent Aggregate marks range and the respective Grades are shown as
follows
Aggregate Marks
Grade
> = 80
A
Less than 80 and > = 65
B
Less than 65 and > = 50
C
Less than 50
D
Public Members
 A function Enter( ) to allow user to enter values for ANo, Name, Agg & call function
GradeMe( ) to find the Grade
 A function Result ( ) to allow user to view the content of all the data members.
15. Define a class ITEM in C++ with following description:
Private members:
 Icode of type integer (Item Code)
 Item of type string (Item Name)
 Price of type Float (Price of each item)
 Qty of type integer (Quantity in stock)
 Discount of type float (Discount percentage on the item)
 A find function finddisc( ) to calculate discount as per the following rule:
If Qty <=50
discount is 0%
If 50 < Qty <=100
discount is 5%
If Qty>100
discount is 10%
Public members :
A function Buy( ) to allow user to enter values for Icode, Item,Price, Qty and call function
Finddisc ( ) to calculate the discount.
A function showall ( ) to allow user to view the content of all the data members.
16. WAP to increment the employee salaries on the basis of there designation
(Manager-5000, General Manager-10000, CEO-20000, worker-2000). Use employee
name, id, designation and salary as data member and inc_sal as member function
17. . Write a class bank, containing data member: Name of Depositor, A/c type, Type of A/c,
Balance amount. Member function: To assign initial value, To deposit an amount, to
withdraw an amount after checking the balance (which should be greater than Rs. 500) ,
To display name & balance.
18. WAP to define nested class ‘student_info’ which contains data members such as name,
roll number and sex and also consists of one more class ‘date’ ,whose data members are
day, month and year. The data is to be read from the keyboard & displayed on the
screen.
19. Create two classes namely Employee and Qualification. Using multiple inheritance
derive two classes Scientist and Manager. Take suitable attributes & operations. WAP to
implement this class hierarchy.
20. Write a C++ program to write number 1 to 100 in a data file NOTES.TXT
21. Create a User-defined function in C++ to read the content from a text file OUT.TXT,
count and display the number of alphabets present in it
22. Create User defined function in C++ to count the number of blank present in a text file
named "OUT.TXT".
23. Create User defined function in C++ to print the count of word the as an independent
word in a text file STORY.TXT
24. Function in C++ to count and display the number of lines not starting with alphabet 'A'
present in a text file "STORY.TXT"
25. User defined function in C++ named copyupper(), that reads the file FIRST.TXT and
creates a new file named SECOND.TXT contains all words from the file FIRST.TXT in
uppercase
26. Write a function in a C++ to read the content of a text file “DELHI.TXT” and display all
those lines on screen, which are either starting with ‘D’ or starting with ‘M’.
27. Write a function in a C++ to count the number of lowercase alphabets present in a text
file “BOOK.txt”.
28. Consider the following class declaration then write c++ function for following file
operations viz create_file, read_file, add new records, modify record, delete a record,
search for a record.
29. Write a program to implement stack using linked list.
30. Write a program to implement insertion and deletions in a linked queue.
31. (i) Create the following Table DEPT with DeptID as Primary Kay.
DeptID
DeptName
MgrID
Location
Number
Varchar
Number
Char(40)
(ii) Insert the following record in the DEPT Table.
DeptID
DeptName
MgrID
Location
10
Sales
8566
Mumbai
20
Personel
8698
Delhi
30
Accounts
Delhi
40
Research
Banglore
(iii) Alter the table EMP as Add a column DeptID (Number)
(iv) Show the minimum, maximum and average salary of Managers.
(v). Count the number of Clerk in the Organization.
(vi). Display the Designation wise list of employees with name, Sal and Date of Joining.
(vii) Count the number of employees who are not getting commission.
(viii) Show the average salary for all departments with more than 5 working people.
(ix). List the count of Employees grouped by DeptID.
(x). Display the maximum salary of employees in each Department.
(xi). Count the number of Employees working in ACCOUNTS department.
(xii). Display the name of employees working in Delhi.
(xiii). Display the name of Employees who is managing SALES department.
(xiv). Display the name of employees who are working in Delhi and getting more than
5000.
Q.32 . Create table CUSTOMER as per following Table structure.
Col Name
CustID
CustName
CustAdd
CustCity
CustPhone
Data Type
Number
Varchar
varchar
varchar
varchar
Length
7
30
40
30
10
Constraint
Primary
Not Null
2. Insert 5 records with relevant information in the Customer table.
3. Update all the records as add ‘Mr.’ with CustName.
4. Add one column Email of data type VARCHAR and size 30 to table Customer.
5. Add one more column CustIncomeGroup of data type VARCHAR(10).
6. Drop the column CustomerIncomeGroup from table Customer.
7. Modify the column CustCity as change the size 40 characters long.
8. Delete all the records who belongs to ‘Jaipur’
9. Create table ORDER as per following Table structure. Also make CustNo as
Foreign Key which refers CustID of CUSTOMER table.
Col Name
OrderNo
CustNo
ItemName
Data Type
Number
Number
varchar
Length
5
7
30
Constraint
Primary
10. Add 5 records as per defined constraints in Order
Qty
Number
5
>=2
table.
Price
Number
6,2
Not Null
11. Create a table TEMPCUSTOMER from existing CUSTOMER table with
CustID, CustName and CustPhone columns.
12. Write command to show the Tables in the MYORG Database.
13. Drop the TEMPCUSTOMER table.
Download