Anda di halaman 1dari 9

Computer Science (083)

Class-XII
List of Programs (2009-10)

1. Write a function to generate the following series using functions passing the
required parameters:-
a. 1 + x2/2! + x3/3!.........xn/n!
b. 1+x2/3!-x3/4!.........xn/n+1!
MACROS
2. Write a program to define following macro/constant and their implementation:
• Area of rectangle
• Area of square
• Area of triangle
• Constant Max = 100
STRING Manipulation
3. Write program to accept a string and display the following menu with out using built-
in functions: -
o String Length.
o Palindrome or not.
o Vowel count
o Change case.
ARRAYS & FUNCTIONS
4. Given two arrays of integers A and B of sizes M and N respectively. Write a function
named MIX() which will produce a third array named C, such that the following
sequence is followed : (HOTS)
All even numbers of A from left to right are copied into C from left to right.
All odd numbers of A from left to right are copied into C from right to left
All even numbers of B from left to right are copied into C from left to right.
All odd numbers of B from left to right are copied into C from right to left
A, B and C are passed as arguments to MIX().
e.g. : A is {3,2,1,7,6,3} and B is {9,3,5,6,2,8,10}, the resultant array C is
{2,6,6,2,8,10,5,3,9,3,7,1,3}
5. 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 (HOTS)
If the array is 1, 2,3,4,5,6 If the array is 1,2,3
The resultant 2D array is given below The resultant 2D array is
1 2 3 4 5 6 given below
1 2 3 4 5 0 1 2 3
1 2 3 4 0 0 1 2 0
1 2 3 0 0 0 1 0 0
1 2 0 0 0 0
1 0 0 0 0 0
STRUCTURES ( Wt. 2)
6. Create a structure student with following members
Roll Name Address Father’s Marks in 5
No. Name Subjects
Add1 A Pin
dd2 Code
Write menu driven program which calls following functions :
• Void create_array(student s[10], int n); // for creating array of structure
student
• Void show_array(student s[10], int n); // for displaying array of structure
student
• Void merit_List(student s[10], int n); //Merit List Generation: - should have the
roll no., name, marks in 5 subjects, total and average. Array to be sorted
according to total (Descending order).
• Void grade_report(student s[10], int n);//Grade report - should have roll no.,
name, total and grade of all the students.
Criteria for grade is -

Average Grade
>=90 A
<90 and >=75 B
<75 and >=60 C
<60 and >=40 D
<40 F

ENUMERATED DATA TYPE( Wt. 1)


7. Write a program to show different rainbow colors of corresponding to the entered
code using enumerated data type.

CLASSES (Wt. 2)
8. Define following class and make menu driven program to call its functions.
class array
{ int a[10];
int n;
public:
void createarray();
void showarray();
void insertion_Sort();
void Binary_search()
};
9. Define following class and make menu driven program for doing various operations:
class arr2d
{ int a[10][10];
int m,n;
public;
void create2D( );
void show2D( );
void show2D_LOWER1( );
void show2D_LOWER2( );
void show2D_UPPER1( );
void show2D_UPPER2( );
void show_Diagonal1( );
void showDiagonal2( );
};
Assuming the2D array to be a square matrix with odd dimensions , i.e 3x3, 5x5,7x7, etc
Example if the array content is
543
678
129
Output through the function void show_Diagonal1( ) and void show_Diagonal2( )
should be
Diagonal one : 5 7 9
Diagonal two : 3 7 1 .
Output through the function void show2D_LOWER1( ) and show2D_LOWER2( ) should be
5 3
67 7 8
129 1 2 9
Output through the function void show2D_UPPER1( ) and show2D_UPPER2( ) should be
543 543
78 67
9 1
10. 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
Display the following menu for atleast 5 employees: -
o Create. To accept data of 5 employee
o Salary statement. To display payslip of 5 employee
o Query in employee number. To accept empno and display relevant data
o Query on employee name. To accept employee name and display relevant
data.
CONSTRUCTOR
11. Write a program to accept the number and compute the factorial.
12. Write a program to generate Tribonacci series.

INHERITANCE
13. 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 (array of
employee) 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
14. Write a program to accept a text file name and display: -
 Number of characters
 Frequency Table
o No of Uppercase character
o No of Vowels
o No of Digits
o No of Words
 Number of lines
15. Write a program to accept the text file name and display the following menu: -
(OPTIONAL)
 Find and replace every character with its subsequent character
 Replace lowercase character with uppercase character

16. Write a program to accept a source file and target file and display the following
menu: - (OPTIONAL)
 Copy contents source to target
 Change case of source to target
 Replace many spaces to one space
 Change contents like “AASTHA” to “aaSTHa”

17. 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
18. Write a program to create an employee class having the following data members: -
Private
Emp_no Integer
Name Character
Address Character
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: - NOTE : Define separate functions for operations
 Create
 Add
 Modify (Using one file)
 Search
 Display
POINTERS
19. Write a program to swap 2 given numbers using pointers.
20. Write a program to create, and display the elements of an integer array using
pointers.
21. 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.

22.Try the following program illustrating the use of this pointer


class one
{ char name[10];
public:
one (char * s) // constructor function
{
strcpy(name, s);
}
void display( )
{
cout <<”current calling object is : “<< name;
cout << “\nPress any key to continue……”;
getch( );
}
};
int main( )
{
one obj1(“Obj1”), obj2(“Obj2”), obj3(“Obj3”);
obj2.display( );
obj3.display( );
}

STACKS and QUEUE


23.Write a program to perform various stack operations like push(), pop(), display() on a
STATIC stack.
24. Write a program to perform various queue operations like insert(), delete(), display()
on a circular queue (array.)
25.Write a program to perform various stack operations like push(), pop(), display() on a
linked stack having following node structure: -
Roll_no Integer
Age Integer

26.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;
};

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
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.