COMPUTER PRACTICAL 2015-16 AISSCE EXAMINATION
SUBMITTED BY: Name: Boards Roll No: Class: XII School:
Acknowledgement I am extremely thankful to the Principal for her encouragement and for all the facilities that she provided for this project work and Computer teachers XYZ, of ABC for giving me the opportunity for this project work. I am very thankful to them for their advice and guidance during the course of my project work.
Signature of Candidate
Certificate This is to certify that X, student of class XII of ABC School has completed the Computer Practical during the academic year 2015-2016 towards partial fulfillment of credit for the Computer Project of AISSCE 2016 and submitted the satisfactory report as completed in the following pages under my supervision and does not involve in plagiarism of any kind. The reference taken in making this project has been declared at the end of this report.
___________________ Teacher’s Signature
Index Sl. no
Date
Programs
1
21/8/15
Write constructor and destructor definition (for a class) that should display the object number being created/destroyed of this type
1
2
28/8/15
Program to illustrate access control of inherited members in the privately derived class
3
3
5/9/15
4
12/9/15
Calculating Sum and Product of two numbers using Inheritance Function Overloading to calculate the area of a circle, rectangle and triangle
Page no.
6
9
Program to create a text file and then create 5
19/9/15
another text file by converting each line of the newly created text file into an uppercase
12
string 6
26/9/15
Program to append data in a file
15
7
29/9/15
Bubble Sort
18
8
1/10/15
Program to demonstrate Queue using Array
20
9
4/10/15
Pushing and Popping in Stack-Array
25
10
7/10/15
Insertion in Queue
29
11
15/10/15
Deletion in Array-Queue
32
12
17/10/15
13
19/10/15
14
25/10/15
15
27/10/15
Addition and deletion of new books using linked list Program to demonstrate the sum of two matrices Program to find the length of the string Program to find the occurrence of character in the string
36
40 43 46
Signature
Remarks
16
31/10/15
A program to illustrate Multiple Inheritance
49
Program to create two arrays to store roll 17
2/11/15
numbers and marks of desired students,
53
whose number would be known at run time 18
5/11/15
19
10/11/15
20
21/11/15
Function to display the elements which lie on middle of row and column Program to check whether the string is palindrome or not Program to check whether the two strings are equal or not
55
58
61
Program to illustrate working of default 21
25/11/15
arguments. Calculate interest amount
64
making use of default arguments
22
1/12/15
23
7/12/15
24
7/12/15
SQL Program for TABLE: STUDENT
K-Map (SOP)
K-Map (POS)
66
70
71
Write constructor and destructor definition (for a class) that should display the object number being created/destroyed of this type: #include
#include class A { static int count; public: A() { count++; cout<<”Object”<
Output of the program for writing constructor and destructor definition (for a class) that should display the object number being created/destroyed of this type:
Program to illustrate access control of inherited members in the privately derived class: #include #include #include const int LEN=25; class Employee { private: char name[LEN]; unsigned long enumb; public: void getdata() { cout<<”Enter Name=”; gets(name); cout<<”Enter Employee Number:”; cin>>enumb; } void putdata() { cout<<”Name:”<>basic; } };
class Manager:public Employee { private: char title[LEN]; public: void getdata() { Employee::getdata(); getbasic(); cout<<”Enter Title:”; gets(title); cout<<”\n”; } void putdata() { Employee::putdata(); cout<<”\tTitle:”<
Output of the program to illustrate access control of inherited members in the privately derived class:
Calculating Sum and Product of two numbers using Inheritance: #include #include class Sum [ public: int a,b,c; void getdata(); void calc(); void show(); }; void Sum::getdata() { cout<<”Enter two numbers=”; cin>>a>>b; } void Sum::calc() { c=a+b; } void Sum::show() { cout<<”Sum=”<
p=a*b; } void SumProduct::showp() { cout<<”\nProduct=”<
Output of the program for calculating Sum and Product of two numbers using Inheritance
Function Overloading to calculate the area of a circle, rectangle and triangle: #include #include #include #include void area(float r) { float area; cout<<"\nArea:"<<(3.14*r*r); } void area(float l,float b) { float area ; cout<<"\nArea:"<>opt;
switch(opt) { case 1:cout<<"\nEnter radius of the circle:"; cin>>r; area(r); break; case 2:cout<<"\nEnter the length and breadth of the rectangle:"; cin>>l>>b; area(l,b); break; case 3:cout<<"\nEnter side 1:"; cin>>x; cout<<"\nEnter side 2:"; cin>>y; cout<<"\nEnter side 3:"; cin>>z; area(x,y,z); break; default:cout<<"Wrong Option!!"; } cout<<"\nDo you wnat to continue?(Y/N):"; cin>>ch; } getch(); }
Output of the program for Function Overloading to calculate the area of a circle, rectangle and triangle:
Program to create a text file and then create another text file by converting each line of the newly created text file into an uppercase string: # include # include # include # include void main() { char fname[20]; char str[80], ch = 'y'; int count; cout << "\n Enter the name of the file "; gets(fname); ofstream oldfile(fname); while ((ch == 'Y') || (ch == 'y')) { cout << "\n Enter a line of text "; gets(str); oldfile << str << "\n"; cout << "\n Want to add more lines (Y/N) "; cin >> ch; } oldfile.close(); // Copy each line after converting into the upper case ofstream temp("temp.dat"); ifstream newfile(fname); while (newfile) { newfile.get(ch); if (ch != '\n') ch = toupper(ch); temp.put(ch);
} newfile.close(); temp.close(); clrscr(); cout<< "\n The output file is \n"; ifstream yfile("temp.dat"); count = 0; while (!yfile.eof()) { yfile.getline(str,80); cout << str << "\n"; count++; // Check whether the number of lines on the display exceed 22 or not if ((count % 22) == 0) { cout << "\n Press any key to continue "; cin >> ch; } } yfile.close(); }
Output of the program to create a text file and then create another text file by converting each line of the newly created text file into an uppercase string:
Program to append data in a file: #include #include #include class stu { int rollno; char name[25]; char Class[4]; float marks; char grade; public: void getdata() { cout<<”Roll no:”; cin>>rollno; cout<<”Name:”; cin>>name; cout<<”Class:”; cin>>Class; cout<<”Marks:”; cin>>marks; if(marks>=75) grade=’A’; else if(marks>=60) grade=’B’; else if(marks>=50) grade=’C’; else if(marks>=40) grade=’D’; else grade=’E’; }
void putdata() { cout<>ans; } of.close(); getch(); }
Output of the program to append data in a file:
Bubble Sort: #include #include void main() { int i,a[10],t,j; clrscr(); cout<<"Enter 10 elements="; for(i=0;i<10;i++) { cin>>a[i]; } for(i=1;i<10;i++) { for(j=0;j<10-i;j++) { if(a[j]
Output of Bubble Sort:
Program to demonstrate Queue using Array: #include #include #include #define SIZE 5 int rear=-1, front=-1; void main() { void insert(int q[], int s, int num); void delete_Q(int q[]); void show(int q[]); int que[SIZE],ch,x; while(1) { cout<<”\nPress:\n1. Insert rear\n2. Delete front\n3. Show\n4. Exit\n”; cout<<”Enter choice=”; cin>>ch; switch(ch) { case 1: cout<<”Enter elements to be inserted=”; cin>>x; insert(que,SIZE,x); break; case 2: delete_Q(que); break; case 3: show(que); break; case 4: exit(0); } } } void insert(int q[],int s, int num) {
if(rear==-1) { front=rear=0; q[rear]=num; } else if(rear==s-1) { cout<<”Queue is full”; } else { rear++; q[rear]=num; } } void delete_Q(int q[]) { if(front==-1) { cout<<”Queue is empty”; } else { cout<<”Elements deleted=”<
void show(int q[]) { int i; if(front==-1) { cout<<”Queue is empty”; } else { cout<<”Elements in the queue are=”; for(i=front;i<=rear;i++) { cout<<”q[i]<<” “; } } }
Output of the program to demonstrate Queue using Array:
Output of the program to demonstrate Queue using Array:
Pushing and Popping in Stack-Array: #include #include #include #include struct Node { int info; Node*next; } *top,*newptr,*save,*ptr; Node*Create_New_Node(int); void Push(Node*); void Display(Node*); void Pop(); void main() { top=NULL; int inf; char ch=’y’; while(ch==’y’ || ch==’Y’) { cout<<”\nEnter information for the new node…”; cin>>inf; newptr=Create_New_Node(inf); if(newptr==NULL) { cout<<”\nCannot create new node!!! Aborting!!\n”; system(“pause”); exit(1); } Push(newptr); cout<<”\n Press Y to enter more nodes, N to exit…”;
cin>>ch; } system(“cls”); do { cout<<”\n The Stack now is: \n”; Display(top); system(“pause”); cout<<”Want to pop an element?(y/n)…”; cin>>ch; if(ch==’Y’ || ch==’y’) Pop(); } while(ch==’y’ || ch==’Y’); getch(); } Node*Create_New_Node(int n) { ptr=new Node; ptr -> info=n; ptr -> next=NULL; return ptr; } void Push(node*np) { If(top=NULL) top=np; else { save=top; top=np; np -> next=save; } }
void Pop() { If(top==NULL) cout<<”UNDERFLOW !!!\n”; else { ptr=top; top=top -> next; delete ptr; } } void Display(Node*np) { while(np!=NULL) { cout< info<<”->”; np=np -> next; } cout<<”!!!\n”; }
Output of the program for Pushing and Popping in Stack-Array:
Insertion in Queue: #include #include #include int Insert_in_Q(int [],int); void Display(int [], int, int); const int size=50; int Queue[size], front=-1, rear=-1; void main() { int Item,res; char ch='y'; clrscr(); while(ch=='y' || ch=='Y') { cout<<"\nEnter item for insertion:"; cin>>Item; res=Insert_in_Q(Queue,Item); if(res==-1) { cout<<"OVERFLOW!!! Aborting!! \n"; exit(1); } cout<<"Now the Queue(Front.........to.........Rear)is:\n"; Display(Queue,front,rear); cout<<"Want to insert more elements?(y/n)..."; cin>>ch; } getch(); } int Insert_in_Q(int Queue[],int ele) {
if(rear==size-1) return-1; else if(rear==-1) { front=rear=0; Queue[rear]=ele; } else { rear++; Queue[rear]=ele; } getch(); } void Display(int Queue[], int front, int rear) { if(front==-1) return; for(int i=front;i
Output of the program for Insertion in Queue:
Deletion in Array-Queue: #include #include #include #include int Remove(int []); int Insert(int [],int); void Display(int [],int,int); const int size=50; int Queue[size],front=-1,rear=-1; void main() { int Item,res; char ch='y'; clrscr(); while(ch=='y' || ch=='Y') { cout<<"\nEnter ITEM for insertion:"; cin>>Item; res=Insert(Queue,Item); if(res==-1) { cout<<"OVERFLOW!!! Aborting!! \n"; exit(1); } cout<<"\n Now the Queue(Front...to...Rear)is:\n"; Display(Queue,front,rear); cout<<"\n Want to insert more elements?(y/n)..."; cin>>ch; } cout<<"Now the deletion of elements begin...(Press y for yes and n for no)\n"; cin>>ch; while(ch=='y' || ch=='Y')
{ res=Remove(Queue); if(res==-1) { cout<<"UNDERFLOW!!! Aborting!! \n"; exit(1); } else { cout<<"\nElements deleted is:"<>ch; } getch(); } int Insert(int Queue[],int ele) { if(rear==size-1) return-1; else if(rear==-1) { front=rear=0; Queue[rear]=ele; } else { rear++; Queue[rear]=ele; } getch(); }
int Remove(int Queue[]) { int ret; if(front==-1) return-1; else { ret=Queue[front]; if(front==rear) front=rear=-1; else front++; } return ret; } void Display(int Queue[],int front,int rear) { if(front==-1) return; for(int i=front;i
Output of the program for Deletion in Array-Queue:
Addition and deletion of new books using linked list: # include # include class NODE { public: int bookno; NODE *link; }; class LINKLIST { private: NODE *first,*last,*temp; public: void NCREATE(int); // Create a linked list with n nodes void insertatk(int); // Inserting at kth position void display(); // Display the linked list }; void LINKLIST::NCREATE( int n) { first = new NODE; cout << "\n Enter the book number "; cin >> first->bookno; first->link = NULL; temp = first; for(int i =1;i> last->bookno; last->link = NULL; temp->link = last; temp = last;
} } void LINKLIST::insertatk(int j) // Function to insert the node at kth position { int i = 0; NODE *newnode,*back; newnode = new NODE; cout<< "\nEnter the data value "; cin>>newnode->bookno; newnode->link = NULL; temp = first; while (i < (j-1)) { back = temp; temp = temp->link; i++; } back->link = newnode; newnode->link = temp; } void LINKLIST::display() //Function to display the link list { temp = first; cout<< "\n The linked list is \n"; while (temp != NULL) { cout<< "\n"<bookno; temp = temp->link; } getch(); } void main() { int ch,n,k;
char ch1 = 'y'; LINKLIST list; clrscr(); cout << "\n Enter how many nodes in the list "; cin >> n; list.NCREATE(n); do { clrscr(); cout<< "\n1. For insert "; cout << "\n2. For display "; cout << "\n3. For quit "; cout << "\nEnter your choice "; cin>>ch; switch (ch) { case 1: cout << "\nEnter the position at which insertion is required "; cin >> k; list.insertatk(k); break; case 2 : list.display(); break; } } while (ch != 3); }
Output of the program for Addition and deletion of new books using linked list
Program to demonstrate the sum of two matrices: #include #include main() { int a[3][3], b[3][3], c[3][3]; int i, j; cout << "\n\t Enter elements of Ist array"; for (i=0; i<3; i++) { for (j=0; j<3; j++) cin >> a[i][j]; } cout << "\n\t Enter elements of IInd array"; for (i=0; i<3; i++) { for(j=0; j<3; j++) cin >> b[i][j]; } for (i=0; i<3; i++) { for(j=0; j<3; j++) c[i][j] = a[i][j] + b[i][j]; } clrscr(); cout << "First matrix is \n"; for (i=0; i<3; i++) { for (j=0; j<3; j++) { cout << a[i][j] << " "; } cout << "\n";
} cout << "Second matrix is\n"; for (i=0; i<3; i++) { for (j=0; j<3; j++) { cout << b[i][j] << " "; } cout << "\n"; } cout << "\nSum of two matrix is \n"; for (i=0; i<3; i++) { for(j=0; j<3; j++) { cout << c[i][j] << " "; } cout << "\n"; } return 0; }
Output of program to demonstrate the sum of two matrices:
Program to find the length of the string: #include #include #include #include //CLASS DECLARATION class strn { char *a; int i; public: void read(); //MEMBER FUNCTIONS void calculate(); }; //END OF CLASS void strn::read() { cout << "\n\t"; cout << "\n\tEnter your name "; gets(a); //TO READ THE STRING } void strn::calculate() { i = 0; while (*(a+i) != '\0') i++; cout << "\n\tThe length of your name is : " << i;; } //M A I N P R O G R A M void main() { strn x; //DECLARATION OF OBJECT clrscr(); cout<< "\n\n\n\t ";
x.read(); x.calculate(); getch(); } //E N D
OF
//CALLING MEMBER FUNCTIONS
MAIN
Output of the program to find the length of the string:
Program to find the occurrence of character in the string: #include #include #include # include //CLASS DECLARATION class strn { char *a; char ch; int i; public: void read(); //MEMBER FUNCTIONS void find(); }; //END OF CLASS void strn::read() { cout << "\n\t"; cout << "\n\tEnter the first string "; gets(a); //TO READ THE STRING } void strn::find() { i = 0; int count = 0; cout << "\n\t Enter the character "; cin >> ch; while (*(a+i) != '\0') { if (*(a + i) == ch) count++; i++; }
cout << "\n\tThe number of times "<< ch << " occur in " << a << " is " << count; } //M A I N P R O G R A M void main() { strn x; //DECLARATION OF OBJECT clrscr(); cout << "\n\n\n\t "; x.read(); //CALLING MEMBER FUNCTIONS x.find(); getch(); } //E N D
OF
MAIN
Output of the program to find the occurrence of character in the string:
A program to illustrate Multiple Inheritance: #include #include #include class admin { int admno; char name[30]; public: void getadmin(); void putadmin(); }; void admin::getadmin() { cout<<"\nEnter admission no: "; cin>>admno; cout<<"\nEnter name: "; gets(name); } void admin::putadmin() { cout<<"\nThe admission no is; "; cout<
}; void acadm::getacadm() { cout<<"\nEnter rollno: "; cin>>rno; cout<<"\nEnter marks: "; cin>>marks; } void acadm::putacadm() { cout<<"\nThe rollno is: "; cout<
putacadm(); cout<<"\nYour house is: "; cout<>n; cout<<"\nEnter student details:"; for(i=0;i
Output of the program to illustrate Multiple Inheritance:
Program to create two arrays to store roll numbers and marks of desired students, whose number would be known at run time: #include #include int*rollno; float*marks; void main() { clrscr(); int size; cout<<"How many elements are there in the array?\n"; cin>>size; rollno=new int[size]; marks=new float[size]; if((!rollno) || (!marks)) { cout<<"Out of memory! Aborting!"; return; } for(int i=0;i>rollno[i]>>marks[i]; } cout<<"Roll no \tMarks\n"; for(i=0;i
Output of the program to create two arrays to store roll numbers and marks of desired students, whose number would be known at run time:
Function to display the elements which lie on middle of row and column: #include #include #include const M = 10; const N = 10; void display_RowCol(int Array[M][N], int r, int c) { clrscr(); int row = r / 2; int col = c / 2; // Finding the middle row cout << "Middle Row : "; for(int j=0; j> r; cout << "Enter total no. of columns: "; cin >> c;
// Array to be a square matrix with odd dimension if ((r == c) && ((r%2==1) && (c%2==1))) { cout << "Input steps"; cout << "\n\Enter the element in the array\n"; for(i=0; i> Array[i][j]; } } else { cout << "Input row and column not valid"; getch(); return; } display_RowCol(Array, r, c); }
Output of the function to display the elements which lie on middle of row and column:
’
Program to check whether the string is palindrome or not: #include #include #include //CLASS DECLARATION class strn { char *a, flag; int i, j, k; public: void read(); //MEMBER FUNCTIONS void ch_pal(); strn() //USE OF CONSTRUCTOR { flag = 'y'; } }; //END OF CLASS void strn::read() { cout << "\n\t"; cout << "\n\tEnter the string "; cin >> a; //TO READ THE STRING } void strn::ch_pal() { cout << "\n\tThe entered string "; for(i=0; *(a+i)!='\0'; i++) cout << *(a+i); for(j=0, i-=1; i>j; j++, i--) { if(*(a + i) != *(a+j)) //CHECKING FOR PALINDROME {
flag = 'n'; break; } } if(flag == 'n') cout << " is not a palindrome "; else cout << " is a palindrome "; } void main() { strn x; //DECLARATION OF OBJECT clrscr(); cout << "\n\n\n\t "; x.read(); //CALLING MEMBER FUNCTIONS x.ch_pal(); cout << "\n\n\t\t bye!"; getch(); }
Output of the program to check whether the string is palindrome or not:
Program to check whether the two strings are equal or not: #include #include #include #include //CLASS DECLARATION class strn { char *a, *b, flag; int i, j, k; public: void read(); //MEMBER FUNCTIONS void compare(); strn() //USE OF CONSTRUCTOR { flag = 'y'; } }; //END OF CLASS void strn::read() { cout << "\n\t"; cout << "\n\tEnter the first string "; gets(a); //TO READ THE STRING cout << "\n\tEnter the second string "; gets(b); //TO READ THE STRING } void strn::compare() { i = 0; j = 0; while (*(a+i) != '\0') i++; while(*(b+j) != '\0')
j++; if (i != j) { cout << "\n\t Strings are not equal "; return; } i = 0; while ((*(a+i) != '\0') && (*(b+i) != '\0')) { if(*(a + i) != *( b + i)) { flag = 'n'; break; } i++; } if(flag == 'n') cout << "\n\tStrings are not equal "; else cout << "\n\tStrings are equal "; } //M A I N P R O G R A M void main() { strn x; //DECLARATION OF OBJECT clrscr(); cout << "\n\n\n\t "; x.read(); //CALLING MEMBER FUNCTIONS x.compare(); cout << "\n\n\t\t bye!"; getch(); } //E N D O F M A I N
Output of the program to check whether the two strings are equal or not:
Program to illustrate working of default arguments. Calculate interest amount making use of default arguments: #include #include #include void amount(float princ, int time=2, float rate=0.08); void amount(float princ, int time, float rate) { cout<<”\nPrincipal Amount= Rs.”<
Output of the program to illustrate working of default arguments. Calculate interest amount making use of default arguments:
TABLE: STUDENT
No:
Name
Stipend
Stream
Avgmark
Grade
Class
1
Karan
400.00
Medical
78.5
B
12B
2
Divakar
450.00
Commerce
89.2
A
11C
3
Divya
300.00
Commerce
68.6
C
12C
4
Arun
350.00
Humanities
73.1
B
12C
5
Sabina
500.00
Nonmedical
90.6
A
11A
6
John
400.00
Medical
75.4
B
12B
7
Robert
250.00
Humanities
64.4
C
11A
8
Rubina
450.00
Nonmedical
88.5
A
12A
9
Vikas
500.00
Nonmedical
92.0
A
12A
10
Mohan
300.00
Commerce
67.5
C
12C
WRITE SQL COMMANDS FOR QUESTIONS 1 TO 7 ON THE BASIS OF TABLE STUDENT
1) Select all the Nonmedical stream students from STUDENT. SELECT NAME FROM STUDENT WHERE STREAM=’NONMEDICAL’;
OUTPUT: NAME: SABINA RUBINA VIKAS 2) List the names of those students who are in class 12 sorted by stipend SELECT NAME, STIPEND FROM STUDENT WHERE CLASS=’12’ ORDER BY STIPEND;
OUTPUT: NAME
STIPEND
DIVYA
300.00
MOHAN
300.00
ARUN
350.00
KARAN
400.00
JOHN
400.00
RUBINA
450.00
VIKAS
500.00
3) List all students sorted by avgmark in descending order: SELECT NAME FROM STUDENT ORDER BY AVGMARK DESC; OUTPUT:
ROBERT MOHAN DIVYA ARUN JOHN KARAN RUBINA DIVAKAR SABINA VIKAS 4) To count the number of students with grade “A” SELECT COUNT(GRADE) FROM STUDENT WHERE GRADE=”A”;
OUTPUT: 4
5) To insert a new student in the table anf fill the columns with some values INSERT INTO STUDENT VALUES (11,”MANISHA”,300.00,”NONMEDICAL”,72.5,”B”,12C);
OUTPUT: ONE ROW ADDED 6) Give the output of the following SQL statement: A) SELECT MIN(AVGMARK) FROM STUDENT WHERE AVGMARK<75; OUTPUT: 64.4
B) SELECT SUM(STIPEND) FROM STUDENT WHERE GRADE=”B” OUTPUT: 1150.00
C) SELECT AVG(STIPEND)FROM STUDENT WHERE CLASS=”12A”; OUTPUT: 475.00 D) SELECT COUNT(DISTINCT) OUTPUT: 10