AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
Computer Practical
1. Computer Science (083)
Class-XII(2008-09)
List of Programs
1. Write a function to generate the following series using functions passing the
required parameters:-
a. 1+x1/1! + x2/2! + x3/3!.........xn/n!
b. 1+x2/3!-x3/4!.........xn/n+1!
c. 1-x2/3!+x3/4!.........xn-1/n!
STRUCTURES
2. Write a program to accept the data of a student having the following
structure:-
Roll Name Address Father’s Marks in 5
No. Name Subjects
Last First Add1 Add2 Pin
Name Name Code
And Display the following menu:-
o Merit List Generation: - should have the roll no., name, marks in 5
subjects, total and average.
o Grade card Generation: - should have roll no., name, total and grade.
Criteria of grade are: -
Average Grade
>=90 A
<90 and >=75 B
<75 and >=60 C
<60 and >=40 D
<40 F
ENUMERATED DATA TYPE
3. Write a program to show different rainbow colors of corresponding to the
entered code using enumerated data type.
MACROS
4. Write a program to define following macro and their implementation:
• Area of rectangle
• Area of square
• Area of triangle
• Constant Max = 100
CLASSES
5. Write a program to accept an array and display the following menu: -
o Insertion Sort.
o Binary search
2. 6. To accept 2 arrays and display the following menu: -
o Merge 2-sorted arrays.
o Even-Odd Sorting.
o Negative-Positive Sorting.
7. To accept a 2-D array and display the following menu: -
o Row total.
o Column total.
o Lower Triangle 1 and 2.
o Upper Triangle 1 and 2.
8. Write program to accept a string and display the following menu with out using
built-in functions: -
o Palindrome or not.
o Frequency Table.
o Change case.
o String Length.
9. Write a program to store the record of an employee with the following details:
-
Private members:
Data members
EmpNo Integer
Name Character
Address Character
Pin code Character
Basic Salary Float
HRA Rate Float
DA Rate Float
PF Rate Float
HRA Float
DA Float
PF Float
GROSS Float
NET Float
• Calculate() to calculate HRA, DA, PF, GROSS and net salary
Public:
• Retempno() function to return empno
• Retename() function to return employee name
• Readdata() to accept employee no, name, address, pincode, Basic salary,
HRA rate, DA rate and PF rate. Invoke function calculate to calculate HRA, DA,
PF, GROSS and net salary
• Displaydata() to display employee no, name, address, pincode, Basic salary,
HRA, DA, PF, GROSS and net salary of the employee
3. Display the following menu :
o Create. (To accept data of 5 employee)
o Salary statement. To display payslip of 5 employee
o Query on employee number. To accept empno and display relevant
data
o Query on employee name. To accept employee name and display
relevant data.
10. Write a program to declare a structure of a student with the following details:
-
Structure student
Adm_No Integer
Name Character
Address Character
Pin Code Character
Class Integer
Marks in 5 Subjects Float
Total Float
Average float
Grade character
Create a class Marks
private
• object of the above structure
• calculate() to calculate total, average and grade
Public member
• Readdata() to accept Adm_No, Name, Address, Pin Code, Class and invoke
calculate function
• Displaydata() to display Adm_No, Name, Address, Pin Code, Class. Total,
average and grade.
Display the following menu for atleast 5 students (use functions): -
o Create. To accept data of 5 student
o Report card to display report card of one student
o Name list to display data sorted on name
o Merit List. To generate merit list
CONSTRUCTOR
11. Write a program to accept the number and compute the factorial.
12. Write a program to generate Tribonacci series.
POINTERS
13. Write a program to swap 2 given numbers.
14. Write a program to create, and display the elements of an integer array.
4. 15. Declare a structure
struct telephone
{
char tno[9];
char name[10];
};
Write the program to do the following :
• Create an array with 5 elements of telephone type and initialize it with
telephone nos. and names of your 5 friends.
• Create a pointer to telephone array
• Display the telephone details of your 5 friends using pointer.
16. Try the following program illustrating the use of this pointer
class one
{ char name[10];
public:
one (char * s) // constructor function
{
strcpy(name, s);
}
one compare(one s)
{
if (strcmp(name,s.name) ==0)
return this;
else
return s;
}
void display( )
{
cout <<”current calling object is : “<< name;
cout << “nPress any key to continue……”;
getch( );
}
};
int main( )
{
one obj1(“Obj1”), obj2(“Obj2”), obj3(“Obj1”);
obj2.display( );
obj3.display( );
one *p=obj1.compare(obj2);
p->display();
p=obj1.compare(obj3);
p->display();
5. }
INHERITANCE
17 Consider the classes:
class person{
private:
char name[20];
protected:
int age;
public:
void readdata();
void displdata();
};
class employee:public person
{
char department[20];
protected:
float salary;
public:
void read();
void write();
float retsal { return salary;}
int retage(){ return age;}
int retdep(char *d)
{ if (strcmp(d,department) == 0)
return 1;
else
return 0;}
};
Complete the above classes and write main function having 5 employees and display a
menu:
1. Create
2. Search on the basis of age
3. Search on the basis of department
4. Search on the basis of salary
FILE HANDLING
17. Write a program to accept a text file name and display: -
Number of characters
6. Frequency Table
o No of Uppercase character
o No of Vowels
o No of Digits
o No of Words
Number of lines
18. Write a program to accept the text file name and display the following menu: -
Find and replace a character
Replace lowercase character with uppercase character
19. Write a program to accept a source file and target file and display the
following menu: -
Copy contents source to target
Change case of source to target
Replace many spaces to one space
Change contents like “AASTHA” to “aaSTHa”
20. Consider the following class
class STUD
{
int Rno;
char Name[20];
public:
void Enter(){cin>>Rno;gets(Name);}
void Display(){cout<<Rno<<Name<<endl;}
};
Write the program which displays the following menu and allows following file
operations assuming the binary file is containing the objects of the above mentioned
class: -
• Create
• Add
• Delete (Using Two files)
(Use remove( ) and rename( ) functions)
• Display
NOTE : Define separate functions for above mentioned operations
21. Write a program to create an employee class having the following data
members: -
Private
Emp_no Integer
Name Character
Address Character
7. Pin Code Character
Basic Float
HRA Float
DA Float
PF Float
Public
Readata() To accept the data
Retempno() Function to return employee no.
Showdata() To show the data
And display the following menu: -
Create
Add
Modify (Using one file)
Search
Display
NOTE : Define separate functions for above mentioned operations
STACKS and QUEUE
22.Write a program to perform various stack operations like push(), pop(), display()
on a STATIC stack.
23.Write a program to perform various queue operations like insert(), delete(),
display() on a circular queue array.
24.Write a program to perform various stack operations like push(), pop(), display()
on a linked stack having following node structure: -
Roll_n Integer
o
Age Integer
25.Write a program to perform
various queue operations like insert(), delete(), display() on a linked queue having
1 integer and 1 floating type data.
Struct Node
{
int x;
float y;
Node *link;
};
26.Write a program to perform reverse a line-using stack having string to store
each word.
8. STRUCTURE QUERY LANGUAGE
27.Create employee tables having the following: -
Empno Number (4)
Deptno Number (2)
Empname Character (20)
Job Character (10)
Manager Number (4)
Hire Date Date
Salary Number (7,2)
Commission Number (7,2)
Query Statements based on that: -
Create a table
Insert 5 records
Display the names of employee whose name starts with “P” or “R”.
Display information of employee getting between Rs. 2000 and 8000.
Display information on the basis of dept_no.
28. Write the outputs of SQL commands given in (h) with the help of the table
shown.
EmpNo Name Job Mgr Hiredate Sal Deptno
Integer Character Character Float Date Float Integer
To select all the information of employee of Dept number 20
Find all employees who are either Clerks or who are earning between 1000
and 2000.
To list names of all employees in ascending order of their salary.
To display employee’s name, Salary, Deptno for only managers.
To count the number of employees with salary <3000.
To insert a new row in the Employee table with the following data: 11,
“MILLER”, “Manager”, 7698, {25/02/98}, 4300, 20.
Give the output of the following SQL statements: -
o Select COUNT(*) from EMPLOYEE.
o Select MIN(Salary) from EMPLOYEE where deptno=20
o Select SUM(Salary) from EMPLOYEE where
department=”Clerk”.
o Select AVG(Salary) from EMPLOYEE.
Consider a table Department having fields as
Deptno Deptname
Integer Character
9. o Display name of employees along with their department having deptno
as 10 or 20.
o Display total salary of each department.
o Display total salary of each department whose employee name starts
with N or P.
o Display total salary of each department whose total salary > 20000.
29.Write the SQL command for (a) to (f) on the basis of the table given below
(DIRECTORY).
DIRECTORY
No. Fname Lname Phone Address
Integer Character Character Float Character
To select all the information of employee of Rohini area.
Update the database set the phone no. as 7047645 where phone number is
7057456.
To create a view called Dir with the following fields-> Fname, Phone and
Address.
To display the data for Arpit, Rahul and Kisan.
To delete the rows where the address is Rohini.
To delete the table physically.