You are on page 1of 192

EXP. NO. 1 DATE: 12-4-12 ARRAYS AIM: To perform insertion, deletion and printing operations on an array. CODE: #include<iostream.h> #include<conio.

h> #include<process.h> int a[101], n, i, lb=0, ub=0; void printing() { cout<<"\nCurrent status of array: \n"; for(i=lb;i<=ub;i++) cout<<a[i]<<" "; cout<<endl; } void insertion() { if(ub-lb+1>101) { cout<<"\nOverflow error!\n"; getch();
1|Page

} else { int pos; cout<<"\nEnter position of insertion: "; cin>>pos; ub++; if(pos<=ub) { for(i=ub;i>=pos+1;i--) a[i]=a[i-1]; cout<<"\nEnter element to be inserted: "; cin>>a[pos]; } else { cout<<"\nEnter element to be inserted: "; cin>>a[pos]; } } printing(); } void deletion() { int pos; cout<<"\nEnter position of deletion: ";
2|Page

cin>>pos; if(pos<=ub) { for(i=pos;i<=ub;i++) a[i]=a[i+1]; ub--; } else cout<<"\nError, cannot delete!\n"; printing(); } void main() { clrscr(); int ch; cout<<"\nCreate your array!\n"; cout<<"\nHow many elements in the array? Number should be <100 : "; cin>>n; cout<<"\nEnter elements of array: \n"; for(i=1;i<=n;i++) cin>>a[i]; lb=1; ub=n; printing(); p: clrscr(); cout<<"\nMain Menu\n"; cout<<"1. Insertion\n";
3|Page

case 3:printing(). exit(0). } } SAMPLE OUTPUT FOR THIS PROGRAM Create your array! How many elements in the array? Number should be <100: 4 4|Page . getch(). goto p. getch(). case 4:cout<<"\nPress any key to exit. Printing\n". getch(). goto p.cout<<"2. cout<<"3. goto p. getch().". cin>>ch. case 2:deletion(). default: cout<<"\nWrong option! Enter again!\n". cout<<"4. switch(ch) { case 1:insertion(). goto p. cout<<"Enter your choice: ". Deletion\n". Exit\n". getch().

Insertion 2. Deletion 3. Printing 4. Exit Enter your choice: 1 Enter position of insertion 3 Enter element to be inserted 3 Current status of array 1 2 3 4 5 Press any key Main Menu 1. Printing 4.Enter elements of array 1 2 4 5 Current status of array 1 2 4 5 Press any key Main Menu 1. Deletion 3. Insertion 2. Exit 5|Page .

Exit Enter your choice: 4 Press any key to exit. Printing 4.Enter your choice: 2 Enter position of deletion 5 Current status of array 1 2 3 4 Press any key Main Menu 1. Deletion 3. Insertion 2. 6|Page .

void insertion() { if(top==100) { cout<<"Overflow error\n". } 7|Page .h> #include<conio. i. top=0. } else { top++.EXP. cin>>stack[top]. CODE: #include<iostream. NO. deletion and printing operations on a static stack.h> int stack[101]. getch(). cout<<"Enter a value to insert\n". 2 DATE: 9-8-12 STACK AS AN ARRAY AIM: To perform insertion.h> #include<process.

} void deletion() { if(top==0) { cout<<"Underflow error\n". top--. for(i=top.i>=1.i--) cout<<stack[i]<<" ". } else { int g=stack[top]. } void main() { int ch. do { 8|Page . getch(). cout<<g<<" deleted!\n". } } void printing() { cout<<"\nCurrent status of stack\n".

cout<<"Enter your choice: ". } SAMPLE OUTPUT FOR THIS PROGRAM Main Menu 1. Deletion\n". break. break. getch(). Deletion 9|Page . exit(0). Insertion 2. cout<<"2. } //end of switch } //end of do loop while ((ch>=1) && (ch<=4)). getch(). cout<<"3. Exit\n". Printing\n". Insertion\n".cout<<"\nMain Menu\n". case 3: printing().". break. case 2: deletion(). case 4: cout<<"Press any key to exit. cout<<"1. switch(ch) { case 1: insertion(). cout<<"4. cin>>ch.

3. Printing 10 | P a g e . Printing 4. Exit Enter your choice: 1 Enter a value to insert 8 Main Menu 1. Insertion 2. Exit Enter your choice: 1 Enter a value to insert 9 Main Menu 1. Exit Enter your choice: 1 Enter a value to insert 7 Main Menu 1. Insertion 2. Deletion 3. Deletion 3. Deletion 3. Insertion 2. Printing 4. Printing 4.

Printing 4. Printing 4. Insertion 2. Deletion 3. Deletion 3. Exit Enter your choice: 2 9 deleted! Main Menu 1. Exit Enter your choice: 4 11 | P a g e . Insertion 2. Deletion 3.4. Exit Enter your choice: 3 Current status of stack 78 Main Menu 1. Exit Enter your choice: 3 Current status of stack 789 Main Menu 1. Printing 4. Insertion 2.

12 | P a g e .Press any key to exit.

void insertion() { if(rear+1>100) { cout<<"Overflow error\n". getch(). } else { if((front==0)&&(rear==0)) front=rear=1. else rear++.EXP. rear=0. 13 | P a g e . deletion and printing operations on a static queue. 3 DATE: 30-8-12 QUEUE AS AN ARRAY AIM: To perform insertion.h> int queue[101].h> #include<conio.h> #include<process. i. front=0. NO. CODE: #include<iostream.

getch(). } } void printing() { cout<<"\nCurrent status of queue\n". 14 | P a g e . } else { int g=queue[front]. cin>>queue[rear].cout<<"Enter an element to insert\n". cout<<g<<" deleted!\n". front++. } else if(front==rear) { int g=queue[front]. } } void deletion() { if(front==0) { cout<<"Underflow error\n". cout<<g<<" deleted!\n". front=rear=0.

break.for(i=front. case 3: printing(). switch(ch) { case 1: insertion(). Insertion\n". case 4: cout<<"Press any key to exit. do { cout<<"\nMain Menu\n". cout<<"1. cout<<"3. } void main() { int ch. cout<<"Enter your choice: ". exit(0). Printing\n".". break. Exit\n". } //end of switch } //end of do loop 15 | P a g e . case 2: deletion().i++) cout<<queue[i]<<" ". cout<<"2. break. cout<<"4. getch(). Deletion\n". cin>>ch.i<=rear.

Deletion 3. } SAMPLE OUTPUT FOR THIS PROGRAM Main Menu 1. Deletion 3. Printing 4. Printing 4. Printing 4. Exit Enter your choice: 1 Enter an element to insert 1995 Main Menu 1. getch().while ((ch>=1) && (ch<=4)). Insertion 2. Exit 16 | P a g e . Exit Enter your choice: 1 Enter an element to insert 19 Main Menu 1. Insertion 2. Insertion 2. Deletion 3.

Enter your choice: 1 Enter an element to insert 12 Main Menu 1. Printing 4. Insertion 2. Exit Enter your choice: 3 17 | P a g e . Exit Enter your choice: 3 Current status of queue 1995 19 12 Main Menu 1. Deletion 3. Insertion 2. Deletion 3. Insertion 2. Exit Enter your choice: 2 1995 deleted! Main Menu 1. Printing 4. Printing 4. Deletion 3.

Deletion 3. Exit Enter your choice: 4 Press any key to exit. Printing 4. Insertion 2. 18 | P a g e .Current status of queue 19 12 Main Menu 1.

EXP. 4 DATE: 16-8-12 STACK AS A LINKED LIST AIM: To perform insertion.h> struct SLL { int a. if(ptr==NULL) { cout<<"Overflow error\n".h> #include<process. 19 | P a g e . CODE: #include<iostream. getch(). void insertion() { ptr=new SLL. } *top. char c. SLL *next. float b.h> #include<conio. *temp. deletion and printing operations on a dynamic stack. NO. *ptr.

cin>>ptr->a>>ptr->b>>ptr->c. c\n". ptr->next=top. b is float. top=ptr. c is char\n". b. cout<<"a is int. } } void printing() { 20 | P a g e . delete(temp). top=top->next.} else { cout<<"Enter values for a. } else { temp=top. } } void deletion() { if(top==NULL) { cout<<"Underflow error\n". getch(). cout<<temp->a<<" "<<temp->b<<" "<<temp->c<<" deleted!\n".

cout<<"2. Exit\n". while(temp!=NULL) { cout<<temp->a<<" "<<temp->b<<" "<<temp->c<<endl. Printing\n". cout<<"4. cin>>ch. case 2: deletion(). break. Deletion\n". case 4: cout<<"Press any key to exit. cout<<"Enter your choice: ". 21 | P a g e .temp=top.". case 3: printing(). break. } } void main() { int ch. break. do { cout<<"\nMain Menu\n". cout<<"1. cout<<"3. switch(ch) { case 1: insertion(). Insertion\n". temp=temp->next.

exit(0). b. Deletion 3.getch(). Insertion 2. Deletion 3. b. Exit Enter your choice: 1 Enter values for a. } SAMPLE OUTPUT FOR THIS PROGRAM Main Menu 1. c is char 4 5. Exit Enter your choice: 1 Enter values for a. getch().44 b 22 | P a g e .3 r Main Menu 1. Insertion 2. b is float. } //end of switch } //end of do loop while ((ch>=1) && (ch<=4)). c is char 6 2. c a is int. b is float. c a is int. Printing 4. Printing 4.

Printing 4. Printing 4.Main Menu 1. Exit Enter your choice: 2 6 2.3 r Main Menu 23 | P a g e . Exit Enter your choice: 3 Current status of stack 4 5. Printing 4. Deletion 3. Exit Enter your choice: 3 Current status of stack 6 2.44 b 4 5. Insertion 2. Insertion 2.44 b deleted! Main Menu 1. Deletion 3.3 r Main Menu 1. Insertion 2. Deletion 3.

Deletion 3. 24 | P a g e . Printing 4. Insertion 2.1. Exit Enter your choice: 4 Press any key to exit.

} *front. char c. 25 | P a g e .EXP. float b.h> #include<process. CODE: #include<iostream.h> struct QLL { int a.h> #include<conio. if(ptr==NULL) { cout<<"Overflow error\n". *ptr. *temp. deletion and printing operations on a dynamic queue. 5 DATE: 6-9-12 QUEUE AS A LINKED LIST AIM: To perform insertion. NO. QLL *next. *rear. getch(). void insertion() { ptr=new QLL.

b.} else if((front==NULL)&&(rear==NULL)) { cout<<"Enter values for a. } } void deletion() { if(front==NULL) { cout<<"Underflow error\n". c is char\n". getch(). cin>>ptr->a>>ptr->b>>ptr->c. b is float. c is char\n". ptr->next=NULL. cout<<"Enter values for a. cout<<"a is int. cin>>ptr->a>>ptr->b>>ptr->c. ptr->next=NULL. front=rear=ptr. b. } else { rear->next=ptr. c\n". c\n". } else if(front==rear) { 26 | P a g e . cout<<"a is int. b is float. rear=ptr.

front=rear=NULL. delete(temp). temp=temp->next.temp=front. } } void printing() { temp=front. while(temp!=NULL) { cout<<temp->a<<" "<<temp->b<<" "<<temp->c<<endl. delete(temp). } else { temp=front. do { 27 | P a g e . front=front->next. cout<<temp->a<<" "<<temp->b<<" "<<temp->c<<" deleted!\n". cout<<temp->a<<" "<<temp->b<<" "<<temp->c<<" deleted!\n". } } void main() { int ch.

} //end of switch } //end of do loop while ((ch>=1) && (ch<=4)). Insertion\n". break. Printing\n". case 3: printing(). exit(0). cout<<"4. Deletion\n". case 2: deletion(). getch(). getch().cout<<"\nMain Menu\n". Deletion 28 | P a g e . break. } SAMPLE OUTPUT FOR THIS PROGRAM Main Menu 1. break. cin>>ch.". cout<<"2. Exit\n". cout<<"1. case 4: cout<<"Press any key to exit. switch(ch) { case 1: insertion(). Insertion 2. cout<<"3. cout<<"Enter your choice: ".

Insertion 2. Insertion 29 | P a g e . Printing 4. c is char 10 5.3. c a is int. b is float. c is char 14 3. Exit Enter your choice: 1 Enter values for a. b. Insertion 2. c a is int. Printing 4. b is float. c a is int. Exit Enter your choice: 1 Enter values for a. Exit Enter your choice: 1 Enter values for a. b. Deletion 3. c is char 25 4.3 c Main Menu 1.14 p Main Menu 1.05 k Main Menu 1. Deletion 3. Printing 4. b. b is float.

Exit Enter your choice: 3 Current status of queue: 10 5. Exit Enter your choice: 3 Current status of queue: 25 4.2. Deletion 3. Printing 4. Insertion 30 | P a g e .3 c deleted! Main Menu 1.05 k 14 3. Deletion 3. Insertion 2. Exit Enter your choice: 2 10 5.14 p Main Menu 1. Deletion 3. Printing 4.05 k 14 3. Insertion 2.14 p Main Menu 1. Printing 4.3 c 25 4.

Printing 4. 31 | P a g e .2. Exit Enter your choice: 4 Press any key to exit. Deletion 3.

NO. void insertion() { if((front==0)&&(rear==10)||(front==rear+1)) { cout<<"Overflow error\n". rear=0. else if(rear==10) rear=1. 6 DATE: 13-9-12 CIRCULAR QUEUE AIM: To perform insertion.h> int cqueue[11].EXP. else rear++. } else if(front==0) front=rear=1. cin>>cqueue[rear]. i. CODE: #include<iostream. cout<<"Enter element to be inserted\n".h> #include<conio. deletion and printing operations on a static circular queue. getch().h> #include<process. 32 | P a g e . j. front=0.

} else if(front==rear) { cout<<cqueue[front]<<" deleted!\n". getch().} void deletion() { if(front==0) { cout<<"Underflow error\n". } } void printing() { if(front==0) { cout<<"Queue is empty!\n". else { cout<<cqueue[front]<<" deleted!\n". } else if(front==10) front=1. } 33 | P a g e . getch(). front=rear=0. front++.

i<=10. Printing\n". Insertion\n".i++) cout<<cqueue[i]<<" ". Exit\n". for(i=front. cout<<"3.else if(front<=rear) { cout<<"Current status of queue:\n". cout<<"Enter your choice: ". cout<<"1.i++) cout<<cqueue[i]<<" ". } else { cout<<"Current status of queue\n". } } void main() { int ch. switch(ch) 34 | P a g e . cout<<"2. for(i=front.j<=rear.i<=rear. cout<<"4. do { cout<<"\nMain Menu\n".j++) cout<<cqueue[j]<<" ". cin>>ch. for(j=1. Deletion\n".

getch(). break. case 2: deletion(). Exit Enter your choice: 1 Enter element to be inserted 16 Main Menu 1.". Insertion 35 | P a g e . case 4: cout<<"Press any key to exit. } //end of switch } //end of do loop while ((ch>=1) && (ch<=4)). Deletion 3. break. exit(0). getch().{ case 1: insertion(). } SAMPLE OUTPUT FOR THIS PROGRAM Main Menu 1. Printing 4. break. Insertion 2. case 3: printing().

Printing 4.2. Deletion 3. Printing 4. Deletion 3. Printing 36 | P a g e . Exit Enter your choice: 3 Current status of queue: 16 35 84 Main Menu 1. Insertion 2. Deletion 3. Deletion 3. Exit Enter your choice: 1 Enter element to be inserted 84 Main Menu 1. Insertion 2. Insertion 2. Printing 4. Exit Enter your choice: 1 Enter element to be inserted 35 Main Menu 1.

Exit Enter your choice: 2 16 deleted! Main Menu 1. Deletion 3. Printing 4. Printing 4. Insertion 2. Deletion 3. Insertion 2. Exit Enter your choice: 4 Press any key to exit.4. Exit Enter your choice: 3 Current status of queue: 35 84 Main Menu 1. 37 | P a g e .

EXP. else high=mid-1.mid. int n. if(a[mid]==data) return(mid). else if(data>a[mid]) low=mid+1.h> #include<process. 38 | P a g e . high=n-1. while(low<=high) { mid=(low+high)/2.high. 7 DATE: 26-4-12 SEARCH IN AN ARRAY AIM: To perform search in an array using linear search and binary search.h> const int size=25.h> #include<conio. low=0. NO. int data) { int low. CODE: #include<iostream. int bs(int a[].

i<n.int n. for(i=0. } return (-1). data. cin>>n. 39 | P a g e . ch. pos. } void main() { int a[size].i<n. cout<<"\nThis is your array\n".i++) cin>>a[i]. while(i<n) { if(a[i]==data) return (i).i++) cout<<a[i]<<" ". cout<<"\nHow many elements? Should be less than "<<size<<endl. i. i++. cout<<"\nEnter the elements of your array in ascending order\n". int data) { int i=0. } int ls(int a[]. for(i=0. n.} return(-1).

break. case 3: cout<<"Press any key to exit. Exit\n". cout<<"2. case 2: cout<<"\nEnter element to be searched\n". break. exit(0). data).". n. Binary Search\n". cout<<"3. switch(ch) { case 1: cout<<"\nEnter element to be searched\n".cout<<endl. pos=ls(a. else 40 | P a g e . Linear Search\n". cin>>data. cin>>data. do { cout<<"\nMain Menu\n". cout<<"1. cin>>ch. data). n. } //end of switch if (pos==-1) cout<<"\n Search unsuccessful!\n". getch(). pos=bs(a. cout<<"Enter your choice: ".

{ cout<<"\n Search successful!\n". Exit Enter your choice: 1 Enter element to be searched 8 Search successful! 41 | P a g e . cout<<data<<" found at position "<<pos+1<<endl. } } //end of do loop while (ch>=1 && ch<=3). getch(). Binary Search 2. Linear Search 3. } SAMPLE OUTPUT FOR THIS PROGRAM How many elements? Should be less than 20 6 Enter the elements of your array in ascending order 112358 This is your array 112358 Main Menu 1.

Binary Search 2. Binary Search 2. Binary Search 2. Exit Enter your choice: 2 Enter element to be searched 2 Search successful! 2 found at position 3 Main Menu 1.8 found at position 6 Main Menu 1. Linear Search 3. Exit Enter your choice: 3 Press any key to exit. Linear Search 3. Linear Search 3. Exit Enter your choice: 2 Enter element to be searched 21 Search unsuccessful! Main Menu 1. 42 | P a g e .

int n) { int i. temp. 8 DATE: 7-6-12 SORTING AN ARRAY AIM: To sort an array using insertion sort. void selection(int a[].pass<n-1. min_index. selection sort and bubble sort.i<n.h> const int size=25. NO.pass++) { min_index=pass. for(i=pass+1.h> #include<conio. pass. } if(pass!=min_index) { temp=a[pass].i++) { if(a[i]<a[min_index]) min_index=i. 43 | P a g e .EXP.h> #include<process. for(pass=0. CODE: #include<iostream.

} } } void bubble(int a[].j>=pos. int n) { int i. 44 | P a g e } . } } void insort(int a[].i<n. if(pos!=i) { for(j=i-1. last. for(i=1. a[min_index]=temp. int n) { int i. current. pass=0. pos.j--) a[j+1]=a[j]. j.i++) { current=a[i]. pos=0. while((pos<i)&&(a[pos]<=current)) pos++. temp. last=n-1. a[pos]=current. exchs.a[pass]=a[min_index]. pass.

n.i++) { if(a[i]>a[i+1]) { temp=a[i]. int a[size].i<last. }while((exchs!=0)&&(pass!=n-1)). p: clrscr().do { pass++. exchs++. cout<<"\nMain Menu\n". exchs=0. a[i+1]=temp. } } last--. } void main() { clrscr(). cout<<"No. of passes used for sorting: "<<pass<<endl. cout<<"\nHow many elements? Should be less than "<<size<<endl. ch. cin>>n. a[i]=a[i+1]. for(i=0. i. 45 | P a g e .

i<=n. cout<<"\nYour array. Insertion Sort\n". Bubble Sort\n". goto p. cout<<endl. cout<<"2. cout<<"This is your array\n".i<=n. cout<<"Enter your choice: ". for(i=1. Selection Sort\n". cin>>ch. for(i=1. cout<<endl. for(i=1. cout<<"\nEnter the elements of new array to be sorted\n". cout<<"4.n). Exit\n".i++) cin>>a[i]. now sorted:\n". cout<<"3.i++) cout<<a[i]<<" ". selection(a. cout<<endl.i++) cout<<a[i]<<" ".i<=n. switch (ch) { case 1: { clrscr(). } case 2: 46 | P a g e . getch().cout<<"1.

i<=n.i++) cout<<a[i]<<" ".i++) 47 | P a g e . cout<<"\nEnter the elements of new array to be sorted\n". for(i=1. cout<<"\nEnter the elements of new array to be sorted\n". cout<<"This is your array\n".{ clrscr().i<=n. } case 3: { clrscr(). for(i=1. for(i=1.i<=n. cout<<endl. cout<<endl. getch().i++) cin>>a[i].i++) cin>>a[i].i<=n. for(i=1. cout<<"\nYour array.i++) cout<<a[i]<<" ". insort(a.n). cout<<endl. cout<<"This is your array\n". cout<<endl. goto p.i<=n. for(i=1. now sorted:\n".

Exit Enter your choice: 1 48 | P a g e . exit(0).i++) cout<<a[i]<<" ". cout<<endl. Selection Sort 2. } case 4: cout<<"\nPress any key to exit". Bubble Sort 4. bubble(a.i<=n. getch(). cout<<"\nYour array.n). Insertion Sort 3. } SAMPLE OUTPUT FOR THIS PROGRAM How many elements? Should be less than 25 5 Main Menu 1. } //end of switch getch(). for(i=1. getch(). goto p.cout<<a[i]<<" ". cout<<endl. now sorted:\n".

Insertion Sort 3. Selection Sort 2. now sorted: 11 33 55 77 99 Main Menu 1.Enter elements of new array to be sorted 55 33 11 99 77 This is your array 55 33 11 99 77 Your array. now sorted: 22 44 66 88 111 49 | P a g e . Bubble Sort 4. Exit Enter your choice: 2 Enter the elements of new array to be sorted 88 44 66 22 111 This is your array 88 44 66 22 111 Your array.

Selection Sort 2.Main Menu 1. Bubble Sort 4. 50 | P a g e . Selection Sort 2. now sorted: 1 2 5 8 21 Main Menu 1. Exit Enter your choice: 4 Press any key to exit. Insertion Sort 3. of passes used for sorting: 1 Your array. Insertion Sort 3. Exit Enter your choice: 3 Enter the elements of new array to be sorted 2 1 5 8 21 This is your array 2 1 5 8 21 No. Bubble Sort 4.

product of two matrices and transpose of a matrix. i.h> int a[100][100]. j. p. void addition() { t: cout<<"\nEnter cin>>m. no. no.EXP. 51 | P a g e . addition.h> #include <process. i. b[100][100]. if(m!=p||n!=q) no. q. cout<<"\nEnter cin>>n. of rows of matrix 1: ".e. 9 DATE: 19-4-12 MATRIX OPERATIONS AIM: To perform operations on a two-dimensional array. m.h> #include <iostream. NO. of columns of matrix 2: ". no. n. of rows of matrix 2: ". k. cout<<"\nEnter cin>>p. of columns of matrix 1: ". CODE: #include <conio. cout<<"\nEnter cin>>q. subtraction.

i<=m. goto t. } cout<<"\nGiven matrix 2 is\n".j<=n.i++) { for(j=1.i++) { for(j=1.i<=m. } cout<<"\nGiven matrix 1 is\n".j++) cin>>a[i][j]. for(i=1.j++) 52 | P a g e . } else { cout<<"\nEnter elements of matrix 1\n".j++) cout<<a[i][j]<<" ".j++) cin>>b[i][j].i++) { for(j=1. cout<<endl. for(i=1. for(i=1.i<=m.i++) { for(j=1. for(i=1.j<=n.j<=n.i<=m. } cout<<"\nEnter elements of matrix 2\n".{ cout<<"\nEnter matrices properly!\n".j<=n.

goto g. of rows of matrix 2: ".i++) { for(j=1. cin>>n.i<=m. cout<<endl. } //end of else } //end of addition void subtraction() { g: cout<<"\nEnter no. cout<<endl. cin>>q. of rows of matrix 1: ".j++) cout<<a[i][j]+b[i][j]<<" ". of columns of matrix 1: ". cout<<"\nEnter no.j<=n. cout<<"\nEnter no. cout<<"\nEnter no. if(m!=p||n!=q) { cout<<"\nEnter matrices properly!\n". cin>>p. } getch(). cin>>m. for(i=1. } cout<<"\nAdded matrix is\n".cout<<b[i][j]<<" ". 53 | P a g e . of columns of matrix 2: ".

} cout<<"\nEnter elements of matrix 2\n". cout<<endl.j<=n.j++) cout<<b[i][j]<<" ".i<=m.i++) { for(j=1.i++) { for(j=1.i<=m. for(i=1.j<=n.j++) cin>>b[i][j].j<=n. } cout<<"\nGiven matrix 1 is\n".i++) { for(j=1. } cout<<"\nGiven matrix 2 is\n".j<=n. cout<<endl. } 54 | P a g e .i<=m.j++) cin>>a[i][j].} else { cout<<"\nEnter elements of matrix 1\n". for(i=1.j++) cout<<a[i][j]<<" ". for(i=1.i<=m.i++) { for(j=1. for(i=1.

of columns of matrix 2: ". cout<<"\nEnter no. } getch(). cout<<endl. } else { 55 | P a g e . cin>>p.j++) cout<<a[i][j]-b[i][j]<<" ". cin>>q.} } //end of subtraction cout<<"\nSubtracted matrix is\n". goto d.i++) { for(j=1.j<=n. void product() { d: cout<<"\nEnter no. cout<<"\nEnter no. of columns of matrix 1: ". if(n!=p) { cout<<"\nEnter matrices properly!\n".i<=m. of rows of matrix 2: ". of rows of matrix 1: ". cout<<"\nEnter no. for(i=1. cin>>n. cin>>m.

i++) { for(j=1. } cout<<"\nGiven matrix 1 is\n".i<=p.j<=q. } cout<<"\nEnter elements of matrix 2\n". for(i=1.i<=m. for(i=1.i++) { for(j=1.j<=q.int c[100][100].j++) cin>>a[i][j].i++) { for(j=1. cout<<endl.j++) cout<<a[i][j]<<" ".i++) 56 | P a g e .j<=n. } cout<<"\nGiven matrix 2 is\n".j<=n.j++) cin>>b[i][j].i++) { for(j=1. cout<<"\nEnter elements of matrix 1\n". for(i=1. for(i=1.i<=m.i<=p. cout<<endl.i<=m. for(i=1.j++) cout<<b[i][j]<<" ". } cout<<"\nThe product of the matrices is\n".

cin>>n. for(k=1.j<=q.k<=n. for(i=1.j++) { c[i][j]=0. } cout<<"\nGiven matrix is\n". cin>>m. of columns of the matrix: ". of rows of the matrix: ". } cout<<endl. cout<<"\nEnter the values of the matrix\n". } //end of for loop getch().i++) { for(j=1.{ for(j=1.i++) { 57 | P a g e .j<=n. for(i=1.i<=m. } //end of else } //end of product void transpose() { cout<<"\nEnter no. cout<<"\nEnter no.i<=m.j++) cin>>a[i][j]. cout<<c[i][j]<<" ".k++) c[i][j]+=a[i][k]*b[k][j].

} cout<<"\nTranspose of the matrix is\n"; for(i=1;i<=n;i++) { for(j=1;j<=m;j++) cout<<a[j][i]<<" "; cout<<endl; } getch(); } void main() { p: clrscr(); cout<<"\nMain Menu\n"; cout<<"1. Addition\n"; cout<<"2. Subtraction\n"; cout<<"3. Product\n"; cout<<"4. Transpose\n"; cout<<"5. Exit\n"; cout<<"Enter your choice: "; int ch; cin>>ch; switch(ch) {
58 | P a g e

for(j=1;j<=n;j++) cout<<a[i][j]<<" "; cout<<endl;

case 1: addition(); goto p; case 2: subtraction(); goto p; case 3: product(); goto p; case 4: transpose(); goto p; case 5: cout<<"\nPress any key to exit."; getch(); exit(0); default: cout<<"\nWrong option! Select again"; getch(); goto p; } } SAMPLE OUTPUT FOR THIS PROGRAM Main Menu 1. Addition 2. Subtraction 3. Product 4. Transpose 5. Exit Enter your choice: 1 Enter no. of rows of matrix 1: 2 Enter no. of columns of matrix 1: 2
59 | P a g e

Enter no. of rows of matrix 2: 2 Enter no. of columns of matrix 2: 2 Enter elements of matrix 1 1001 Enter elements of matrix 2 0220 Given matrix 1 is 10 01 Given matrix 2 is 02 20 Added matrix is 12 21 Main Menu 1. Addition 2. Subtraction 3. Product 4. Transpose 5. Exit Enter your choice: 2 Enter no. of rows of matrix 1: 3
60 | P a g e

of columns of matrix 2: 3 Enter elements of matrix 1 2 3 4 3 4 5 4 5 5 Enter elements of matrix 2 1 -3 5 0 2 4 3 0 4 Given 2 3 3 4 4 5 Given 1 -3 0 2 3 0 matrix 1 is 4 5 5 matrix 2 is 5 4 4 Subtracted matrix is 1 6 -1 3 2 1 1 5 1 Main Menu 1. of rows of matrix 2: 3 Enter no.Enter no. Addition 2. Subtraction 3. Product 61 | P a g e . of columns of matrix 1: 3 Enter no.

Transpose 5. of columns of matrix 2: 3 Enter elements of matrix 1 2 1 3 2 -1 1 Enter elements of matrix 2 000000 Given matrix 1 is 2 1 3 2 -1 1 Given matrix 2 is 000 000 The product of the matrices is 000 000 000 Main Menu 62 | P a g e .4. Exit Enter your choice: 3 Enter Enter Enter Enter no. of rows of matrix 1: 3 no. of columns of matrix 1: 2 no. of rows of matrix 2: 2 no.

Addition 2. Product 4. Exit Enter your choice: 4 Enter no. Exit Enter your choice: 5 Press any key to exit.1. Transpose 5. Subtraction 3. Addition 2. of rows of the matrix: 3 Enter no. Transpose 5. of columns of the matrix: 2 Enter the values of the matrix 1 -2 -3 2 1 -2 3 2 1 Given matrix is 1 -2 -3 2 1 -2 321 Transpose of the matrix is 123 -2 1 2 -3 -2 1 Main Menu 1. Product 4. 63 | P a g e . Subtraction 3.

char department[50]. class person { char name[50].h> #include<stdio. 10 DATE: 26-7-12 SINGLE LEVEL INHERITANCE AIM: To maintain a database of employees and managers using single level inheritance. NO. cin>>emp_no.h> int i. count=0. m.h> #include<conio. public: int emp_no. CODE: #include<iostream. char address[50].h> #include<ctype.h> #include<process. cout<<"Name: ". 64 | P a g e . void readdata() { cout<<"\nEmployee number: ".EXP. n.

: "<<emp_no<<endl. puts(department). cout<<"Name : ". } int give_emp_no(int j) { int flag=0. cout<<endl. cout<<endl. } void displaydata() { cout<<"Employee no. return flag. cout<<"Address: ". cout<<"Department: ". } } e[100]. cout<<"Department: ". void readmandata().gets(name). gets(department). gets(address). 65 | P a g e . puts(name). puts(address). if(j==emp_no) flag=1. class manager: public person { public: int numemp. cout<<"Address: ".

cout<<"No. 66 | P a g e . int get_a_no(int o) { int fi=0.void showmandata(). } } f[100]. } void manager:: showmandata() { displaydata(). void manager::readmandata() { readdata(). if(o==emp_no) fi=1. cin>>numemp. } void menu() { p: clrscr(). cout<<"\nMain Menu\n". return fi. of employees working under him/her: "<<numemp<<endl. cout<<"No. of employees working under him/her: \n".

} case 2: { cout<<"\nHow many managers?\n". Accepting manager details\n". Exit\n".cout<<"1. goto p. switch(ch) { case 1: { cout<<"\nHow many employees: ".readdata(). cin>>m. int ch. cout<<"\nDetails saved!".i++) e[i]. cout<<"4. getch(). cout<<"\nDetails saved!". Display employee details\n". Display manager details\n".i<=m. cout<<"2. getch().readmandata(). 67 | P a g e . for(i=1. cin>>n. cout<<"Enter your choice: ".i<=n. for(i=1. goto p. cin>>ch. Accepting employee details\n". cout<<"5. cout<<"3.i++) f[i].

e[i]. f[i]. if(fl==1) { cout<<"\nDetails of manager "<<i<<endl.i<=n. no of manager) for displaying details: ". break. for(i=1. } else 68 | P a g e .i++) { cout<<"Details of employee "<<i<<endl. cin>>code.} case 3: { clrscr().i<=m.displaydata(). fl.showmandata(). clrscr().get_a_no(code). goto p.i++) { fl=f[i]. } getch(). } case 4: { int code. for(i=1. cout<<"\nEnter manager code(emp.

". Display employee details 4. } SAMPLE OUTPUT FOR THIS PROGRAM Main Menu 1. Accepting employee details 2. menu(). goto p. Accepting manager details 3.cout<<"\nEnter correct codes!\n". getch(). } } void main() { clrscr(). exit(0). } default: goto p. } getch(). } case 5: { cout<<"Press any key to exit. Display manager details 69 | P a g e . getch().

Accepting manager details 3. Exit Enter your choice: 1 How many employees? : 2 Enter details of employee 1 Employee number: 10 Name: Mona Lisa Address: Museum de Louvre Department: Accounts Enter details of employee 2 Employee number: 8 Name: Ubanish Lahari Address: Anfield Department: Research Details saved! Main Menu 1. Display employee details 4.5. Accepting employee details 2. Exit Enter your choice: 2 How many managers? : 1 Enter details of manager 1 70 | P a g e . Display manager details 5.

of employees working under him/her: 3 Details saved! Main Menu 1. : 5 Name: Brendan Rodgers Address: Liverpool Department: HR No. Accepting manager details 3. Display employee details 4. Accepting employee details 2. Exit Enter your choice: 3 Details of employee 1 Employee number: 10 Name: Mona Lisa Address: Museum de Louvre Department: Accounts Details of employee 2 Employee number: 8 Name: Ubanish Lahari Address: Anfield Department: Research 71 | P a g e .Employee no. Display manager details 5.

Accepting manager details 3. 72 | P a g e . Exit Enter your choice: 4 Enter manager code (emp. Accepting manager details 3. Accepting employee details 2. Display employee details 4. : 5 Name: Brendan Rodgers Address: Liverpool Department: HR No.Main Menu 1. of employees working under him/her: 3 Main Menu 1. no of manager) for displaying details: 5 Details of manager 1 Employee no. Display employee details 4. Display manager details 5. Accepting employee details 2. Display manager details 5. Exit Enter your choice: 5 Press any key to exit.

void displayperson() { cout<<"Name: ". LEN).write(name. NO.EXP.h> const int LEN=80.h> #include<conio. } }. cout.h> #include<stdio. 11 DATE: 2-8-12 MULTILEVEL INHERITANCE AIM: To create the annual report of a college using multilevel inheritance. 73 | P a g e . class Person { char name[LEN]. cout<<"\nAge: "<<age<<endl. public: void readperson(). int age. CODE: #include<iostream.

} void disp_rollno() { cout<<"Roll no: "<<rollno<<endl. } float getaverage() { 74 | P a g e . cout<<"Enter roll number: ". cin>>average. } class Student:public Person { int rollno. cout<<"Enter age: ". public: void readstudent() { readperson(). cout<<"Enter name of the person: ".void Person::readperson() { for(int i=0. cout<<"Enter average marks: ".i++) name[i]=' '.i<LEN. cin>>rollno. cin>>age. float average. gets(name).

return average. cout<<"Working? (Y/N): ". class GradStudent:public Student { char subject[LEN]. 75 | P a g e . cout. } char workstatus() { return working. void displaysubject() { cout<<"Subject: ". LEN). void GradStudent::readit() { readstudent(). char working.i<LEN.i++) subject[i]=' '. } }. public: void readit(). } }. gets(subject).write(subject. cout<<"Enter main subject: ". for(int i=0.

int year. nwperc. non_working=0. total++. total=0. else non_working++. i<size. for(int i=0. number=i. float topscore=0. div1=0.getaverage().workstatus()=='Y') num_working++. score=grad[i]. } if(score>=60. grad[i].readit(). if(grad[i]. if(score>topscore) { topscore=score. } 76 | P a g e .0) div1++. number. cin>>year. score. GradStudent grad[size]. } int main() { clrscr(). i++) { cout<<"\nEnter details for graduate "<<i+1<<endl. wperc. num_working=0. cout<<"Enter year: ". const int size=5.cin>>working.

cout<<endl<<nwperc<<"% of the graduates this year are non-working and "<<wperc<<"% are first divisioners!\n".displaysubject(). wperc=((float)div1/(float)total)*100. grad[i]. grad[i]. cout<<"Non-working graduates: "<<non_working<<endl. nwperc=((float)non_working/(float)total)*100. i=number. cout<<"-------------------------------------------------------------------------\n". cout<<"\nAverage marks: "<<grad[i]. getch().clrscr(). cout<<"\n"<<"\t\tReport for the year "<<year<<endl.getaverage()<<endl.displayperson(). cout<<"Working graduates: "<<num_working<<endl. cout<<"\nDetails of the Top Scorer\n". } SAMPLE OUTPUT FOR THIS PROGRAM Enter year: 2012 Enter details for graduate 1 Enter name of the person: Mark Zuckerberg Enter age: 20 77 | P a g e . return 0.

Enter roll number: 3 Enter average marks: 98 Enter main subject: Computers Working? (Y/N): Y Enter details for graduate 2 Enter name of the person: Eduardo Saverin Enter age: 22 Enter roll number: 12 Enter average marks: 845 Enter main subject: History Working? (Y/N): N Enter details for graduate 3 Enter name of the person: Dustin Moskovitz Enter age: 20 Enter roll number: 13 Enter average marks: 65 Enter main subject: Mech Working? (Y/N): N Enter details for graduate 4 Enter name of the person: Bill Gates Enter age: 22 Enter roll number: 4 Enter average marks: 94 Enter main subject: Arts Working? (Y/N): N 78 | P a g e .

Enter details for graduate 5 Enter name of the person: Chuck Norris Enter age: 23 Enter roll number: 18 Enter average marks: 83 Enter main subject: English Working? (Y/N): Y Report for the year 2012 ---------------------------------------------------------------Working graduates: 2 Non-working graduates: 3 Details of the Top Scorer Name: Mark Zuckerberg Age: 20 Subject: Computers Average marks: 98 60% of the graduates this year are non-working and 100% are first divisioners! 79 | P a g e .

cin>>age. 12 DATE: 20-7-12 MULTIPLE INHERITANCE AIM: To maintain a database of students using multiple inheritance. 80 | P a g e . NO. j.h> #include<stdio. gets(name). cout<<endl.h> #include<ctype. i.h> #include<process.h> #include<conio.h> int n. class person { char name[100].EXP. public: void readdata() { cout<<"Enter person's name: ". CODE: #include<iostream. int age. cout<<"Enter person's age: ".

gets(subject). char grade. class subject { char subject[50]. } }. } void displaysubject() { cout<<"Subject: ". cout<<"Age: "<<age<<endl. mark. class student:person.} void dispdata() { cout<<"Name: ". subject { int roll. cout<<endl. puts(name). } }. public: void readsubject() { cout<<"Enter subject: ". puts(subject). 81 | P a g e .

cout<<"Enter student's mark: ". computegrade(). readsubject(). cout<<"Grade: "<<grade<<endl. 82 | P a g e . else if ((mark>200)&&(mark<=240)) grade='C'. cout<<endl. displaysubject(). cin>>mark. cout<<"Mark: "<<mark<<endl. cout<<"Enter student's roll no.public: void getdata() { readdata(). else if ((mark>240)&&(mark<=320)) grade='B'. cin>>roll. } void showdata() { dispdata(). } void computegrade() { if(mark<=200) grade='D'.: ". else if(mark>320) grade='A'.

for(i=1. Display details\n". cout<<"How many students? : ". } 83 | P a g e .cout<<endl. cout<<endl. cout<<"2. cin>>ch. cout<<"1. } } e[100].i<=n. Exit\n". cout<<"Enter your choice: ". cout<<"3. Enter details\n". void menu() { p: clrscr(). cout<<"The multiple inheritance program!\n\n".i++) { cout<<”\nEnter details of student “<<i<<endl. int ch. switch(ch) { case 1: { cout<<"\nAccepting details\n\n". cin>>n. cout<<"\nMain Menu\n".getdata(). e[i].

} default: goto p. for(i=1. menu(). } case 3: { cout<<"Press any key to exit.i++) { cout<<"Details of student "<<i<<endl.i<=n. } getch(). getch(). 84 | P a g e cout<<"Details saved!\n". goto p. .". } } void main() { clrscr(). e[i]. exit(0). goto p.} case 2: { cout<<"\nDisplaying details\n\n".showdata(). getch().

: 12 student‟s mark: 265 details of student 2 person‟s name: Katy Perry person‟s age: 17 subject: Math student‟s roll no. Exit Enter your choice: 1 Accepting details How many students? : 2 Enter Enter Enter Enter Enter Enter Enter Enter Enter Enter Enter Enter details of student 1 person‟s name: Bruno Mars person‟s age: 16 subject: English student‟s roll no. } SAMPLE OUTPUT FOR THIS PROGRAM Main Menu 1. Enter details 2.getch(). Display details 3. : 16 student‟s mark: 350 85 | P a g e .

Exit Enter your choice: 3 86 | P a g e .Details saved! Main Menu 1. Enter details 2. Display details 3. Exit Enter your choice: 2 Displaying details Details of student 1 Name: Bruno Mars Age: 16 Subject: English Mark: 265 Grade: B Details of student 2 Name: Katy Perry Age: 17 Subject: Math Mark: 350 Grade: A Main Menu 1. Display details 3. Enter details 2.

87 | P a g e .Press any key to exit.

i. long price.EXP. int stock. public: stocks() { price=0. char publisher[100].h> #include<conio. char title[100].h> #include<process.h> int n. CODE: #include<iostream.h> #include<string. NO.h> #include<ctype. 13 DATE: 21-6-12 CONSTRUCTORS AND DESTRUCTORS AIM: To maintain the database of a bookshop with implementation of constructors and destructors. 88 | P a g e .h> #include<stdio. class stocks { char author[100].

return flag. cout<<"\nEnter stock: ". char t[]) { int flag=0. gets(publisher). } void getdata() { cout<<"\nEnter title: ". cout<<"\nEnter author: ". } void display().stock=0. int check(char a[]. } void calculate(int). 89 | P a g e . author)==0)&&(strcmp(t. cin>>price. cin>>stock. gets(title). gets(author). if((strcmp(a. title)==0)) flag=1. cout<<"\nEnter publisher: ". } stocks(int &r) { stock=r. cout<<endl. cout<<"\nEnter cost: ".

if(copies>stock) { cout<<"Sorry! Not enough stock!\n\n". } else { cout<<"\nThanks for visiting! Come back later :)\n". cin>>ans. exit(0).". sto=0. stocks s1(sto). } } } 90 | P a g e . cout<<"Press any key to exit. getch(). void stocks::calculate(int copies) { char ans. int fla=1. break. if(toupper(ans)=='Y') { cout<<"\nPurchased!\n". st=0.} e[100]. stock=0. while(fla) { cout<<"Do you want to purchase "<<stock<<" copies?\n".

Adding books to database\n". cout<<"Publisher: ". cout<<"Author: ". Exit\n". cout<<"2. st=stock-copies. cout<<"3. 91 | P a g e . stocks s2(st). puts(publisher). puts(author). cout<<"Cost: "<<price<<endl. Purchasing book(s)\n". cout<<"1. puts(title). cout<<"Stock: "<<stock<<endl. cout<<"\nMain Menu\n". } } void stocks::display() { cout<<"Title: ". } void menu() { p: clrscr().else { cout<<"\nBook purchased!\n". stock=st.

int ch. pos. } case 2: { int noofcopies.i<=n. gets(ti).cout<<"What would you like to do? : ". cin>>ch. char au[100]. goto p. for(i=1. ti[100]. cin>>n.getdata(). e[i].i++) 92 | P a g e . switch(ch) { case 1: { cout<<"\nHow many books are you entering? : ". for(i=1. gets(au). int fla=0.i<=n. q: cout<<"Enter the title you are looking for: ". } cout<<"\nBooks added!\n". getch().i++) { cout<<"\nEnter details of book "<<i. cout<<"\nEnter the author you are looking for: ".

cout<<"How many copies do you need? : ".check(au. } else { cout<<"\nHere are the details of your book! \n\n". } getch(). goto p. cout<<"Enter again!\n". cin>>noofcopies.ti). break. cout<<endl.calculate(noofcopies). goto q. e[pos]. } case 3: { cout<<"\nThanks for coming! Press any key to exit. if(fla==1) { pos=i. e[pos]. 93 | P a g e . } } if(fla==0) { cout<<"Sorry! We don't have such a book!\n".{ fla=e[i].display().".

Purchasing book(s) 3. } default: { cout<<"\nWrong option! Enter again!\n". getch(). goto p.getch(). getch(). menu(). } } } void main() { clrscr(). exit(0). } SAMPLE OUTPUT FOR THIS PROGRAM Main Menu 1. Exit What would you like to do? : 1 How many books are you entering? : 2 94 | P a g e . Adding books to database 2.

Purchasing book(s) 3.Enter details of book 1 Enter title: Champions League Dreams Enter author: Rafa Benitez Enter publisher: Pan Macmillan Enter cost: 295 Enter stock: 5 Enter details of book 2 Enter title: Steven Gerrard: My Liverpool Story Enter author: Steven Gerrard Enter publisher: Zebra Press Enter cost: 595 Enter stock: 4 Books added! Main Menu 1. Adding books to database 2. Exit What would you like to do? : 2 Enter the title you are looking for: Champions League Dreams 95 | P a g e .

96 | P a g e .. Adding books to database 2. Exit What would you like to do? : 3 Thanks for coming! Press any key to exit.Enter the author you are looking for: Rafa Benitez Here are the details of your book! Title: Champions League Dreams Author: Rafa Benitez Publisher: Pan Macmillan Cost: 295 Stock: 5 How many copies do you need? : 7 Sorry! Not enough stock! Do you want to purchase 5 copies? : Y Purchased! Main Menu 1. Purchasing book(s) 3.

void dispdata(). class bank { char name[100]. char type.h> #include<ctype.h> #include<stdio. void withdraw(float wit).h> #include<process. NO. void initialise(). CODE: #include<iostream. 14 DATE: 12-7-12 BANK PROGRAM (CLASS) AIM: To create a program to maintain the records of a bank with the help of a class. n. long balance. 97 | P a g e . void deposit(float amt).h> int i. long acc_no.EXP.h> #include<conio. public: int check(int).

cin>>type. cout<<"\nAmount deposited! \n". } void bank::withdraw(float wit) { char ans. type=toupper(type).} c[50]. void bank::initialise() { cout<<"Enter name of account holder: ". balance+=amt. cout<<"Balance: "<<balance<<endl. cout<<"Enter account no. cin>>balance. gets(name). cout<<"Enter account type(S/C): ". } void bank::deposit(float amt) { clrscr(). cout<<"Enter balance: ". : ". if((balance-wit)<1000) { 98 | P a g e . cin>>acc_no.

cin>>ans. if(ans=='y'||ans=='Y') { balance=1000.cout<<"\nMinimum balance for maintaining account is Rs. cout<<"Balance: "<<balance<<"\n\n".\n". cout<<"Account type: "<<type<<endl. cout<<"\nAmount withdrawn!\n".\n". } 99 | P a g e . cout<<"Do you want to withdraw "<<balance-1000<<" rupees? (Y/N): ". cout<<"You can withdraw maximum of "<<balance-1000<<" rupees. puts(name). cout<<"Balance: "<<balance<<endl. } } void bank::dispdata() { cout<<"\nAccount number: "<<acc_no<<endl. } } else { balance-=wit. cout<<"\nAmount withdrawn!\n". 1000. cout<<"Account holder's name: ".

Initialise accounts\n". Deposit money in an account\n". p: clrscr(). cout<<"4.i++) 100 | P a g e . cout<<"\nMain Menu\n". cout<<"1. cin>>ch.i<=n. cout<<"5. Exit\n". return flag. Withdraw money from an account\n". switch(ch) { case 1: { cout<<"\nHow many accounts are you initialising? : ". cout<<"3. cout<<"2. if(aceno==acc_no) flag=1. cout<<"Enter your choice: ".int bank::check(int aceno) { int flag=0. Display account details\n". for(i=1. } void menu() { int ch. cin>>n.

check(acno).i++) { flag=c[i]. if(flag==1) { cout<<"\nEnter the amount to be deposited: ". cout<<"\nEnter account number: ". } case 2: { long int acno. for(i=1.deposit(amt). } 101 | P a g e .i<=n. } else flag=0. c[i]. float amt. cin>>acno. } cout<<"\nData saved!\n". c[i]. cin>>amt. getch(). break.{ cout<<"\nEnter details for account holder "<<i<<endl. q: int flag=0.initialise(). goto p.

if(flag==0) { cout<<"\nNo such account number exists!\n"; int count=1; while(count==1) { char ans; cout<<"\nDo you want to re-enter account number? (Y/N): "; cin>>ans; if(ans=='y'||ans=='Y') { getch(); goto q; } else if(ans=='n'||ans=='N') { getch(); goto p; } } } getch(); goto p; } case 3: { long int ano; float tot;
102 | P a g e

int flag=0; r: cout<<"\nEnter account number: "; cin>>ano; for(i=1;i<=n;i++) { flag=c[i].check(ano); if(flag==1) { cout<<"\nEnter the amount to be withdrawn\n"; cin>>tot; c[i].withdraw(tot); break; } else flag=0; } if(flag==0) { char ans; cout<<"\nNo such account number exists!\n"; int count=1; while(count==1) { cout<<"\nDo you want to re-enter account number? (Y/N): "; cin>>ans; if(ans=='y'||ans=='Y') { getch();
103 | P a g e

goto r; } else if(ans=='n'||ans=='N') { getch(); goto p; } } getch(); goto p; } case 4: { int no, flag=0; s: cout<<"\nEnter the account number whose details you wish to see: "; cin>>no; for(i=1;i<=n;i++) { flag=c[i].check(no); if(flag==1) { c[i].dispdata(); break; } else flag=0; }
104 | P a g e

}

cin>>ans. while(count==1) { cout<<"\nDo you want to re-enter account number? (Y/N): ". 105 | P a g e . } case 5: { cout<<"\nPress any key to exit. int count=1.if(flag==0) { char ans. if(ans=='y'||ans=='Y') { getch(). } else if(ans=='n'||ans=='N') { getch(). cout<<"\nNo such account number exists!\n". goto p. goto s. } } } getch().\n". goto p. getch().

getch().exit(0). } default: { cout<<"\nWrong option! Enter again!\n". getch(). } } } void main() { clrscr(). menu(). Exit Enter your choice: 1 How many accounts are you initializing? : 2 106 | P a g e . goto p. Initialise accounts 2. Display account details 5. } SAMPLE OUTPUT FOR THIS PROGRAM Main Menu 1. Deposit money in an account 3. Withdraw money from an account 4.

Display account details 5. Exit Enter your choice: 2 Enter account number: 69 Enter the amount to be deposited: 15000 Amount deposited! Balance: 35000 107 | P a g e . : 10 account type (S/C) : C balance: 35000 Data saved! Main Menu 1. Deposit money in an account 3. Initialise accounts 2. : 69 account type (S/C) : S balance: 20000 details for account holder 2 name of account holder: Heath Ledger account no. Withdraw money from an account 4.Enter Enter Enter Enter Enter Enter Enter Enter Enter Enter details for account holder 1 name of account holder: Bradley Cooper account no.

Withdraw money from an account 4. Exit Enter your choice: 3 Enter account number: 10 Enter the amount to be withdrawn: 5000 Amount withdrawn! Balance: 30000 Main Menu 1. Display account details 5. Deposit money in an account 3. Display account details 5. Deposit money in an account 3. Initialise accounts 2. Exit Enter your choice: 4 Enter the account number whose details you wish to see: 69 Account number: 69 Account holder‟s name: Bradley Cooper Account type: S Balance: 35000 108 | P a g e . Initialise accounts 2. Withdraw money from an account 4.Main Menu 1.

Initialise accounts 2. Withdraw money from an account 4. Deposit money in an account 3.Main Menu 1. Display account details 5. Exit Enter your choice: 5 Press any key to exit. 109 | P a g e .

int). void disprec(). float salary.h> #include<stdio. public: int check(long). NO.h> #include<ctype. 15 DATE: 5-7-12 EMPLOYEE PROGRAM (CLASS) AIM: To create a program to maintain the records of employees in a company with the help of a class.h> #include<conio. class employee { char name[100]. sno=1. 110 | P a g e .EXP. n. void getdata(). void displist(int. }e[100]. long reg_no.h> #include<process. CODE: #include<iostream. char designation[100].h> int i.

void employee::getdata() { cout<<"Enter employee name: "; gets(name); cout<<"Enter registration no.: "; cin>>reg_no; cout<<"Enter salary: "; cin>>salary; cout<<"Enter designation: "; gets(designation); cout<<endl; } void employee::disprec() { cout<<"\nEmployee name: "; puts(name); cout<<"Registration no. : "<<reg_no<<endl; cout<<"Salary: "<<salary<<endl; cout<<"Designation: "; puts(designation); cout<<endl; } void employee::displist(int cord, int sno) { gotoxy(1,cord); cout<<sno; gotoxy(5,cord);
111 | P a g e

}

puts(name); gotoxy(21,cord); cout<<reg_no; gotoxy(41,cord); cout<<salary; gotoxy(49,cord); puts(designation); cout<<"\n\n";

int employee::check(long aceno) { int fla=0; if(aceno==reg_no) fla=1; else fla=0; return fla; } void add(int po) { if(po<=n) { for(i=n;i>=po;i--) e[i+1]=e[i]; e[po].getdata(); } if(po==n+1) e[po].getdata();
112 | P a g e

n++; } void del(int post) { for(i=post;i<n;i++) e[i]=e[i+1]; n--; } void menu() { p: clrscr(); cout<<"\nMain Menu\n"; cout<<"1. Accepting employee details\n"; cout<<"2. Displaying particular employee record\n"; cout<<"3. Displaying entire employee database\n"; cout<<"4. Adding employee to database\n"; cout<<"5. Deleting employee from the database\n"; cout<<"6. Exit\n"; cout<<"Enter your choice: "; int ch; cin>>ch; switch(ch) { case 1: { cout<<"\nHow many employees? : ";
113 | P a g e

for(i=1. q: cout<<"\nEnter employee number to display details: ".i<=n. if(flag==1) { e[i].} case 2: { long accno.i<=n. break. for(i=1. cin>>accno.i++) { cout<<"\nEnter details of employee "<<i<<endl. } if(flag==0) { cout<<"\nNo such employee number exists!\n". int flag=0.disprec().i++) { flag=e[i].check(accno). } getch().getdata(). 114 | P a g e cin>>n. } else flag=0. . e[i]. goto p.

cin>>ans. goto p.4). if(toupper(ans)=='Y') goto q. cout<<"\nThe entered employee details are: \n\n". else if(toupper(ans)=='N') goto p. 115 | P a g e . gotoxy(21. gotoxy(1.4). gotoxy(5. cout<<"Employee name".4). } } getch().4). cout<<"Sno". cout<<"Registration no. gotoxy(41.int cc=1.4). cout<<"Salary". cout<<"Designation"<<"\n\n". while(cc) { cout<<"\nDo you want to re-enter? (Y/N) : ". } case 3: { clrscr().". char ans. gotoxy(49.

cin>>pos.int coord=6. so+=1. } int pos. } case 4: { cout<<"\nThe details of the entered employees are:\n\n". u: cout<<"\nIn which position do you want to add the record? : ". while(cc) 116 | P a g e . for(i=1. so=1.i<=n. goto p. int cc=1.i++) { e[i]. for(i=1.i++) { cout<<i<<".displist(coord. coord+=2. char ans.so). if(pos>n+1) { cout<<"Position "<<n+1<<" is vacant!\n\n". e[i]. } getch().i<=n."<<"\n".disprec().

goto p. goto p. getch(). pos=0. cin>>ans. } else if(toupper(ans)=='N') { getch(). 117 | P a g e . add(pos). } case 5: { t: cout<<"\nEnter employee number for deletion: ". int flag=0. long ano. goto u.{ cout<<"Do you want to add the employee over there? (Y/N) : ". cout<<"\nEmployee added!\n". if(toupper(ans)=='Y') { getch(). cin>>ano. } } } cout<<endl.

} } if(flag==0) { cout<<"\nNo such employee number exists!\n". cout<<"\nEmployee deleted!\n". break. if(toupper(ans)=='Y') goto t. } } del(pos). char ans.for(i=1. cin>>ans.i<=n. getch(). int cc=1. goto p.check(ano). while(cc) { cout<<"\nDo you want to re-enter? (Y/N) : ".i++) { flag=e[i]. } 118 | P a g e . else if(toupper(ans)=='N') goto p. if(flag==1) { pos=i.

} default: { cout<<"\nWrong option! Enter again!". exit(0).case 6: { cout<<"\nPress any key to exit. getch(). Adding employee to database 119 | P a g e . } } } void main() { clrscr(). goto p. } SAMPLE OUTPUT FOR THIS PROGRAM Main Menu 1. Accepting employee details 2. getch(). menu(). Displaying particular employee record 3. Displaying entire employee database 4.". getch().

Exit Enter your choice: 2 120 | P a g e . Displaying particular employee record 3. : 10 salary: 8000 designation: Secretary details of employee 2 employee name: Robin van Persie registration no. Deleting employee from database 6. : 20 salary: 35000 designation: Manager Details saved! Main Menu 1.5. Deleting employee from database 6. Displaying entire employee database 4. Adding employee to database 5. Exit Enter your choice: 1 How many employees? : 2 Enter Enter Enter Enter Enter Enter Enter Enter Enter Enter details of employee 1 employee name: Michael Owen registration no. Accepting employee details 2.

Enter employee no. to display details: 20 Employee name: Robin van Persie Registration no. Adding employee to database 5. Accepting employee details 2. Deleting employee from database 6. Employee name: Michael Owen Registration no. Employee name: Robin van Persie Registration no. : 20 Salary: 35000 Designation: Manager 121 | P a g e . Exit Enter your choice: 4 The details of the entered employees are: 1. : 10 Salary: 8000 Designation: Secretary 2. : 20 Salary: 35000 Designation: Manager Main Menu 1. Displaying particular employee record 3. Displaying entire employee database 4.

Adding employee to database 5. Displaying particular employee record 3. : 30 Enter salary: 30000 Enter designation: Sales Executive Employee added! Main Menu 1. Accepting employee details 2. Deleting employee from database 6.no Salary Designation 10 20 30 8000 35000 30000 Secretary Manager Sales Executive 122 | P a g e .In which position do you want to add the record: 3 Enter employee name: Jesus Fernandes Saez Enter registration no. Exit Enter your choice: 3 The entered employee details are: Sno Employee name 1 2 3 Michael Owen Robin van Persie Jesus Fernandes Saez Reg. Displaying entire employee database 4.

Adding employee to database 5. Exit Enter your choice: 5 Enter employee number for deletion: 20 Employee deleted! Main Menu 1. Deleting employee from database 6. 123 | P a g e .Main Menu 1. Deleting employee from database 6. Displaying particular employee record 3. Displaying particular employee record 3. Accepting employee details 2. Accepting employee details 2. Exit Enter your choice: 6 Press any key to exit. Displaying entire employee database 4. Displaying entire employee database 4. Adding employee to database 5.

h> #include<process.i.h> #include<conio. MEDIAN. void mean() { int sum=0. n.i++) { sum=sum+a[i]. CODE: #include<iostream.i<n. } void median() 124 | P a g e . for(i=0. NO. } cout<<"\nMean: "<<(float)(sum/n). median. MODE AND STANDARD DEVIATION AIM: To create a program to calculate the mean. getch(). mode and standard deviation of a set of numbers. 16 DATE: 18-10-12 CALCULATION OF MEAN.h> int a[100].EXP.h> #include<math.

{ cout<<"\nMedian: "; if((n-1)%2==0) { cout<<a[n/2]; } else { cout<<(a[n/2]+a[(n+2)/2])/2; } getch(); } void mode() { int b[100][2], c=0, t, k=0, i, j; c=a[0]; for(i=0;i<100;i++) { b[i][0]=0; } b[0][1]=a[0]; for(i=0;i<n;i++) { if(a[i]==c) { b[k][0]++; } else
125 | P a g e

{ c=a[i]; k++; b[k][0]++; b[k][1]=a[i]; } } for(i=0;i<=k;i++) { for(j=0;j<k;j++) { if(b[j][0]<b[j+1][0]) { int t=b[j][0]; b[j][0]=b[j+1][0]; b[j+1][0]=t; t=b[j][1]; b[j][1]=b[j+1][1]; b[j+1][1]=t; } } } c=b[0][0]; for(i=0;i<=k;i++) { if(b[i][0]==c) { cout<<"\nMode: "<<b[i][1]<<endl; }
126 | P a g e

else break; } getch();

}

void stddev() { int sum=0, i; float x, dev=0, z=0; for(i=0;i<n;i++) { sum=sum+a[i]; } x=sum/n; for(i=0;i<n;i++) { dev=dev+pow((x-a[i]),2); } z=dev/n; cout<<"\nStandard deviation: "<<(float)(sqrt(z)); getch(); } void main() { clrscr(); int ch, i, j; cout<<"How many numbers? : "; cin>>n;
127 | P a g e

cout<<"Enter your choice: ". a[j]=a[j+1]. cout<<"3.i<n. cout<<"4. cin>>ch. Mode\n". Exit\n". 128 | P a g e . switch(ch) { case 1: mean().i++) { for(j=0. cout<<"1.i<n. Mean\n". //sorting the array for(i=0. Standard Deviation\n". for(i=0. cout<<"2.i++) cin>>a[i].j++) { if(a[j]>a[j+1]) { int t=a[j]. cout<<"5.cout<<"\nEnter the numbers\n". } } } p: cout<<"\n\nMain Menu\n". goto p.j<n-1. a[j+1]=t. Median\n".

goto p. Median 3. goto p. case 5: cout<<"\nPress any key to exit. default: cout<<"\nWrong option! Enter again!". } //end of switch } //end of main SAMPLE OUTPUT FOR THIS PROGRAM How many numbers? : 10 Enter the numbers 12 22 20 36 22 19 43 40 40 30 Main Menu 1. Exit Enter your choice: 1 129 | P a g e . goto p. case 4: stddev().case 2: median(). Mean 2. Mode 4. goto p. Standard Deviation 5. case 3: mode().". exit(0). getch().

Mode 4. Median 3. Standard Deviation 5.Mean: 28 Main Menu 1. Exit Enter your choice: 2 Median: 33 Main Menu 1. Mean 2. Mode 4. Mode 4. Median 3. Mean 2. Exit Enter your choice: 3 Mode: 22 Mode:40 Main Menu 1. Median 3. Standard Deviation 130 | P a g e . Standard Deviation 5. Mean 2.

Mean 2. 131 | P a g e . Exit Enter your choice: 4 Standard deviation: 10.26645 Main Menu 1.5. Median 3. Standard Deviation 5. Exit Enter your choice: 5 Press any key to exit. Mode 4.

float k. q3_sal. tot_sal. public: salesman() { strcpy(name.h> #include<conio. float j. q1_sal=i. NO.h> class salesman { char name[11]. float q1_sal. " "). float i. 17 DATE: 11-11-12 SALESMAN PROGRAM (POINTERS) AIM: To find the salesman with the maximum sales from a group of salesmen with the help of pointers. 132 | P a g e . q2_sal.EXP. float l) { strcpy(name. q2_sal=j. } void getdata(char *s. s). q1_sal=q2_sal=q3_sal=q4_sal=0. q4_sal.h> #include<string. CODE: #include<iostream.

} float get_q4() { return q4_sal. } float get_tot() { 133 | P a g e .q3_sal=k. } float get_q1() { return q1_sal. } float get_q3() { return q3_sal. } float get_q2() { return q2_sal. } void calc_tot() { tot_sal=q1_sal+q2_sal+q3_sal+q4_sal. } char *get_name() { return name. q4_sal=l.

cout<<"\nName: ". } 134 | P a g e . if(f1<f2) S=this. cout<<"\nTotal sales: "<<sp->get_tot()<<endl. char *ss=sp->get_name(). cout<<endl. } }. f2. cout. f2=this->get_tot().11). else { float f1. } return S.return tot_sal. } salesman *max_sal(salesman *S) { if(!S) S=this. f1=S->get_tot(). void printit(salesman *sp) { cout<<"\nSalesman with maximum sales: \n".write(ss. salesman *sp.

cout<<"\nEnter sales in four quarters for Aguero: \n". cin>>q1>>q2>>q3>>q4. 135 | P a g e .q2. sp=Ganso. sp=Cazorla.q3. cout<<"\nEnter sales in four quarters for Torres: \n". Ganso. cout<<"\nEnter sales in four quarters for Ganso: \n".calc_tot().q4).max_sal(sp).q2. Caroline. Aguero.void main() { clrscr().q1.q4).getdata("Cazorla". cin>>q1>>q2>>q3>>q4. sp=Torres.max_sal(sp).calc_tot().q1.q1.q4).q4). Aguero. sp=Aguero. q4. cin>>q1>>q2>>q3>>q4. q3. //Enter whatever names you want in the correct places salesman Torres.getdata("Aguero".max_sal(sp).getdata("Torres".calc_tot().q1. Ganso. Cazorla.getdata("Ganso".q3. sp=&Torres. cin>>q1>>q2>>q3>>q4.max_sal(sp). cout<<"\nEnter sales in four quarters for Caroline: \n".q3. Torres. q2. float q1.calc_tot().q3. Cazorla. Aguero. Cazorla. cout<<"\nEnter sales in four quarters for Cazorla: \n". Ganso.q2.q2. Torres.

max_sal(sp).getdata("Caroline".q2. Caroline.q3. Caroline.q1.cin>>q1>>q2>>q3>>q4. printit(sp). } SAMPLE OUTPUT FOR THIS PROGRAM Enter sales in four quarters for Torres: 520 400 320 410 Enter sales in four quarters for Cazorla: 250 350 400 260 Enter sales in four quarters for Aguero: 260 350 400 410 Enter sales in four quarters for Ganso: 136 | P a g e .calc_tot(). getch(). sp=Caroline.q4).

260 360 450 240 Enter sales in four quarters for Caroline: 240 500 120 300 Salesman with maximum sales: Name: Torres Total sales: 1650 137 | P a g e .

open("recpr13.h> #include<string.EXP.h> #include<process. cin.ios::out). f.h> #include<stdio.500. f<<a.getline(a. f. and perform various operations on it. void getdata() { ofstream f.close(). cout<<"\nPoem saved!\n".'$').h> #include<ctype.txt".h> #include<conio. NO. } void display() 138 | P a g e . 18 DATE: 27-9-12 TEXT FILE AIM: To use file handling to create a poem in the form of a text file.h> char a[500]. CODE: #include<fstream.

f.open("recpr13. } return sp.ios::in).txt". f. while(f.seekg(0). char ch='\0'.seekg(0). f>>a.close().get(ch)) cout<<ch. f.get(ch)) { if(ch==' ') sp++. while(f. } int lines() { 139 | P a g e .{ ifstream f. } int spaces() { ifstream f. int sp=0. f>>a.txt". f. f.open("recpr13.ios::in). char ch.

f>>a.get(ch)) { if(ch=='\n') li++.txt".seekg(0). int th=0.open("recpr13. char ch. char word[5].ifstream f. while(f."The")==0)) th++.ios::in). f>>a. int li=0. } int the() { ifstream f. f. } 140 | P a g e .seekg(0).open("recpr13.txt". f. } return th. while(f>>word) { if((strcmp(word. } return li. f."the")==0)||(strcmp(word.ios::in). f.

while(f. Count the no.') { f. if(isalpha(ch)||isspace(ch)||ch=='\n') se++. char ch. } } return se. f>>a.seekg(0). cout<<"2.int sentences() { ifstream f. cout<<"3. 141 | P a g e . f. of spaces in the poem\n". Count the no. } void menu() { j: clrscr().get(ch). cout<<"\nText File: Main Menu\n".open("recpr13.get(ch)) { if(ch=='. cout<<"1.txt". Accept a poem\n". int se=0. f.ios::in). of lines in the poem\n".

cout<<"\nThe entered story is\n\n". switch(ch) { case 1: { clrscr(). cout<<"Enter your choice: ". getch(). cout<<endl. int ch.cout<<"4. cin>>ch. 142 | P a g e . cout<<"Enter your story!\n". display(). of occurences of 'the' in the poem\n". int sp=0. cout<<"\nThe entered poem is\n\n". cout<<"5. of sentences in the poem\n". Count the no. cout<<"Use '$' in the next line to end the poem. Count the no.\n\n". } case 2: { clrscr(). cout<<"\nThe no. Exit\n". goto j. cout<<"6. sp=spaces(). of spaces in the story is: "<<sp<<endl. getdata(). display().

goto j. } case 4: { clrscr(). getch(). cout<<"\nThe entered poem is\n\n". cout<<"\nThe no. int se=0. display(). l=lines(). cout<<"\nThe entered poem is\n\n". cout<<"\nThe no. } case 3: { clrscr(). cout<<endl. int l=0. cout<<endl.getch(). getch(). of lines in the poemis: "<<l<<endl. goto j. display(). se=sentences(). } case 5: { 143 | P a g e . of sentences in the poemis: "<<se<<endl. goto j.

getch(). menu(). th=the(). int th=0. getch(). of occurences of 'the' is: "<<th<<endl. } default: goto j. exit(0). } } void main() { clrscr(). cout<<endl.clrscr(). cout<<"\nThe no.". goto j. cout<<"\nThe entered poem is\n\n". getch(). } case 6: { cout<<"\nPress any key to exit. display(). } SAMPLE OUTPUT FOR THIS PROGRAM 144 | P a g e .

Life is a maze. $ Poem saved! The entered poem is I am just a little bit. Text File: Main Menu 1. Accept a poem 145 | P a g e . I am just a little bit. Count the no. of spaces in the poem 3. Exit Enter your choice: 1 Enter your poem! Use „$‟ in the next line to end the poem. of occurrences of „the‟ in the poem 6. Accept a poem 2. Count the no.Text File: Main Menu 1. Life is a maze. Caught in the middle. And love is a riddle. of sentences in the poem 5. Count the no. Caught in the middle. of lines in the poem 4. Count the no. And love is a riddle.

of sentences in the poem 5. Count the no. Caught in the middle. of occurrences of „the‟ in the poem 6. Count the no. Accept a poem 2. 146 | P a g e . of spaces in the poem is: 15 Text File: Main Menu 1. Count the no. of spaces in the poem 3. Count the no. Count the no. Count the no. of spaces in the poem 3. of lines in the poem 4.2. Count the no. Life is a maze. of occurrences of „the‟ in the poem 6. Count the no. Caught in the middle. Exit Enter your choice: 3 The entered poem is I am just a little bit. And love is a riddle. Exit Enter your choice: 2 The entered poem is I am just a little bit. The no. of lines in the poem 4. of sentences in the poem 5.

Count the no.Life is a maze. Count the no. Accept a poem 2. Count the no. The no. of sentences in the poem 5. Accept a poem 2. of spaces in the poem 3. Count the no. Count the no. of sentences in the poem 5. And love is a riddle. The no. Life is a maze. Count the no. And love is a riddle. of lines in the poem 4. of lines in the poem 4. of sentences in the poem is: 2 Text File: Main Menu 1. of spaces in the poem 3. Caught in the middle. Exit Enter your choice: 4 The entered poem is I am just a little bit. Count the no. Count the no. of occurrences of „the‟ in the poem 147 | P a g e . of lines in the poem is: 4 Text File: Main Menu 1. of occurrences of „the‟ in the poem 6.

Exit Enter your choice: 6 Press any key to exit. Accept a poem 2. of spaces in the poem 3. Caught in the middle. Count the no. of sentences in the poem 5. Count the no.6. The no. Count the no. of lines in the poem 4. Exit Enter your choice: 5 The entered poem is I am just a little bit. of occurrences of „the‟ in the poem 6. Life is a maze. And love is a riddle. of occurrences of „the‟ are: 1 Text File: Main Menu 1. Count the no. 148 | P a g e .

gets(name). i.h> #include<conio.h> #include<string. rollno.h> #include<process. mark. public: void getdata() { cout<<"\nEnter name: ". int clas. class stud { char name[100].h> #include<ctype. CODE: #include<fstream.EXP. 149 | P a g e . NO.h> #include<stdio. cout<<"Enter class: ". cin>>clas.h> int n. 19 DATE: 4-10-12 BINARY FILE AIM: To use file handling to maintain records of students in the form of a binary file.

} void putdata() { cout<<"\nName: ". int cls. cout<<"\nEnter new class (enter -1 to retain old one) : ". cout<<"Enter mark: ". cin>>mark. gets(nm).".nm). cout<<"Class: "<<clas<<endl. if(cls!= -1) clas=cls. cout<<"Mark: "<<mark<<endl. cout<<"\nEnter new mark (enter -1 to retain old one) : ". if(mrk!= -1) 150 | P a g e . if(strcmp(nm.: ". putdata(). } void modify() { char nm[100]. cin>>mrk. cout<<"\nEnter new name (enter '. cout<<"Roll no. puts(name). cin>>rollno.")!=0) strcpy(name. mrk. cin>>cls.' to retain old one) : ".cout<<"Enter roll no.: "<<rollno<<endl.

cout<<"4. cout<<"5. cout<<"2. Exit\n". b. Delete a student's data\n". } int retno() { return rollno. cin>>ch. ofstream f. int ch.mark=mrk. Accept students' data\n".open("cs. } } e[100]. cin>>n. cout<<"1. cout<<"\nBinary File: Main Menu\n". switch(ch) { case 1: { cout<<"\nHow many students? : ". cout<<"Enter your choice: ".ios::out). void menu() { q: clrscr().dat". Modify a student's data\n". cout<<"3. f. Insert a student's data\n". c. 151 | P a g e .

} f. e[i].i<=n.for(i=1.sizeof(e[i])). } cout<<"\nEnter details of student to be inserted\n".ios::in).getdata().close().write((char*)&e[i]. f.sizeof(e[i])). ifstream g. 152 | P a g e .ios::out|ios::app). h. cin>>pos. goto q.dat".i++) { g. g. b.write((char*)&e[i].read((char*)&e[i]. getch().open("temp. ofstream h.i++) { cout<<"\nEnter details of student "<<i<<endl. cout<<"\nEnter position in which you want to enter the student: ".dat".i<=n. g.sizeof(e[i])).seekg(0). for(i=1. cout<<"\nDetails saved!".getdata(). } case 2: { int pos.open("cs. h.

} fio.sizeof(e[i])). fio.write((char*)&b.dat"). cout<<"\nEnter the roll no.h. rename("temp. cout<<"\nHere are the contents of the file after insertion:\n". of student for deletion: ". remove("cs. h.sizeof(c))) { c.read((char*)&c.dat"). ifstream k. ifstream fio. } case 3: { int no. 153 | P a g e .i++) { g.ios::in).dat".sizeof(e[i])). getch().close().write((char*)&e[i]. cin>>no.read((char*)&e[i]. fio.close().close(). while(fio.putdata(). h. goto q.i<=n. } g.sizeof(e[i])).dat".open("cs."cs.seekg(0). for(i=pos.

k. char ans='y'.write((char*)&c.ios::out|ios::app).dat". k.retno()==no) { cout<<"\Are you sure you want to delete this record?(Y/N): ".close(). rename("temp1. } 154 | P a g e .sizeof(b))) { b. remove("cs. ifstream file. ofstream o.sizeof(c))) { if(c. o.putdata().dat".dat").dat").write((char*)&c. while(k.dat". } k. while(file. cin>>ans.open("cs. file.read((char*)&b. if(toupper(ans)=='N') o. cout<<"\nHere are the contents of the file after deletion:\n". o.open("temp1.read((char*)&c.ios::out|ios::beg).seekg(0)."cs.dat".close().sizeof(c)). } else o.open("cs.ios::in).sizeof(c)).

write((char*)&c. ifstream m. while(!gio.sizeof(c)).read((char*)&b.open("cs.} case 4: { int rno.close().dat". . cout<<"\nEnter roll no. int pos. gio. } } gio.seekg(pos). getch(). break. cin>>rno. fstream gio. cout<<"\nThe contents of the file after modification:\n". gio.eof()) { pos=gio. goto q.dat".tellg(). gio. m.read((char*)&c. if(c.modify().ios::in|ios::beg).ios::in|ios::out|ios::beg). gio.sizeof(b))) 155 | P a g e file. while(m.retno()==rno) { c. of student for modification: ".open("cs.sizeof(c)).close().

".putdata(). Delete a student‟s data 156 | P a g e . getch(). Accept students‟ data 2. } default: goto q. } case 5: { cout<<"\nPress any key to exit. } getch(). goto q.{ b. exit(0). } } void main() { clrscr(). menu(). } SAMPLE OUTPUT FOR THIS PROGRAM Binary File: Main Menu 1. Insert a student‟s data 3. getch().

Modify a student‟s data 5. Accept students‟ data 2. : 13 mark: 78 Enter details of student 2 Enter Enter Enter Enter name: Bruce Wayne class: 12 roll no. : 4 mark: 89 Details saved! Binary File: Main Menu 1. Exit Enter your choice: 2 157 | P a g e . Modify a student‟s data 5. Insert a student‟s data 3.4. Delete a student‟s data 4. Exit Enter your choice: 1 How many students? : 2 Enter details of student 1 Enter Enter Enter Enter name: Ra‟s al Ghul class: 10 roll no.

Accept students‟ data 158 | P a g e . : 1 mark: 66 Here are the contents of the file after insertion: Name: Ra‟s al Ghul Class: 10 Roll no. : 1 Mark: 66 Binary File: Main Menu 1. : 4 Mark: 89 Name: Alfred Pennyworth Class: 11 Roll no. : 13 Mark: 78 Name: Bruce Wayne Class: 12 Roll no.Enter position in which you want to enter the student: 3 Enter details of student to be inserted Enter Enter Enter Enter name: Alfred Pennyworth class: 11 roll no.

Exit Enter your choice: 4 159 | P a g e . of student for deletion: 13 Are you sure you want to delete this record?(Y/N): Y Here are the contents of the file after deletion: Name: Bruce Wayne Class: 12 Roll no. Delete a student‟s data 4. Modify a student‟s data 5. Exit Enter your choice: 3 Enter the roll no. Accept students‟ data 2. : 4 Mark: 89 Name: Alfred Pennyworth Class: 11 Roll no.2. : 1 Mark: 66 Binary File: Main Menu 1. Modify a student‟s data 5. Delete a student‟s data 4. Insert a student‟s data 3. Insert a student‟s data 3.

Delete a student‟s data 160 | P a g e . Insert a student‟s data 3. : 1 Mark: 66 Binary File: Main Menu 1.‟ to retain old one) : .Enter roll no. : 4 Mark: 93 Name: Alfred Pennyworth Class: 11 Roll no. Enter new class (enter -1 to retain old one) : -1 Enter new mark (enter -1 to retain old one) : 93 The contents of the file after modification: Name: Bruce Wayne Class: 12 Roll no. Accept students‟ data 2. : 4 Mark: 89 Enter new name (enter „. of student for modification: 4 Name: Bruce Wayne Class: 12 Roll no.

Modify a student‟s data 5.4. 161 | P a g e . Exit Enter your choice: 5 Press any key to exit.

20 DATE: 14-6-12 REPORT CARD GENERATION AIM: To generate the report card of a batch of students with the help of structures.h> #include<string. struct subject { char subjects[20]. int mark[5]. check[50]. CODE: #include<iostream.h> #include<process. cor[50]. flag. long int rollno.h> #include<conio. 162 | P a g e . char corr[50]. total. fail[50]. } count[50]. NO.h> #include<stdlib. struct student { char name[25].h> int n. temp.EXP.h> #include<stdio. rank.

cin>>n. cout<<"\n\tSTUDENT DETAILS\n".mark[j]=atoi(gets(tp)). "English"). for(int i=1. cout<<"\nRoll no. strcpy(sub[5]. "CS"). cout<<"\nEnter details of student "<<i<<endl.j<=5. "Chemistry"). cout<<endl.subjects. cout<<"\nHow many students? : ".name).mark[j]. strcpy(sub[4]. strcpy(sub[3]. gets(count[i]. } 163 | P a g e . cin>>count[i]. "Maths").subjects.i<=n.subjects. for(int j=1. void getdata() { clrscr().total+=count[i]. "Physics"). count[i].subjects.rollno.i++) { count[i].} sub[5].total=0. count[i]. strcpy(sub[2].subjects<<": ".subjects. strcpy(sub[1].j++) { cout<<"\nMark in "<<sub[j].: ". cout<<"\nName: ". char *tp.

i<=n.j<=n-1.j++) 164 | P a g e .i++) { for(int j=1.i++) { fail[l]=count[i]. for(i=1. l++.h<=5.rollno. } l=1.total. cout<<"\nThe entered details are: \n". int l=4. l++.i++) { cout<<"\nStudent "<<i<<endl.i<=n.name.: "<<count[i].h++) { if(count[i].cout<<"\n\n". for(i=1. cout<<"\n\n". cout<<"\nName: "<<count[i].i<=n. } int temp. } clrscr(). for(int h=1.mark[h]==0) temp=count[i]. for(i=1.total. } cout<<count[i]. cout<<"\nRoll no.

total=temp. count[5].total.i<=n.total) { temp=fail[j].{ if(fail[j]. for(int j=1. count[2]. strcpy(corr.flag=0. } } int k=1. } void rank() { 165 | P a g e } .mark[j]==0||count[i].mark[j]<33) { check[k]=i. strcpy(cor.j<=5. for(i=1.i++) { count[i].total.name).total=fail[j+1].name). count[i]. fail[j+1]. fail[j].total<fail[j+1].j++) { if(count[i].total=0. } } } cout<<"\n\nDetails saved!\n".

strcpy(tell[j+1]. tell[k+1]. u). int k=1.j<=k.i++) { tell[k]=count[i]. tell[j+1].total) { t=tell[j].name). tell[j+1].total=0.total=t.student tell[50]. k++. int ran=1.name). tell[j].i<=n. char *u.name. } } } int ctr=0. for(i=1. tell[j].name.i++) { for(int j=1.total<tell[j+1]. int cnt=0.i<=k+1. } k--.total=tell[j+1]. int t. 166 | P a g e .total.j++) { if(tell[j]. for(int i=1. strcpy(u. strcpy(tell[j].total.

for(int r=1. tell[j]. } else { for(k=1.rank=ran.l<=n+1. cnt++.total) { tell[l].j<=n+1.j++) { if(tell[i]. tell[i]. for(int l=j+1.rank=ran.i++) { for(j=i+1. } } ctr++.r++) ran++.k++) { 167 | P a g e .total=0.int j.i<=n.l++) { if(tell[j].r<=ctr.total) { cnt=0.k<=ctr.total==tell[j]. break. tell[n+1]. i+=ctr+cnt.rank=ran. for(i=1.total==tell[l].

total==0) count[i]. } else tell[i-1]. l++. ctr=0.rank=ran+1.i++) { if(count[i]. } } if(tell[i-1]. for(i=1.total==tell[i-2].rank=0.rank=ran. int l=1. } for(i=1. } 168 | P a g e } . break.i++) { count[l]=tell[i].rank=ran+1.i<=n. } tell[i]. } cout<<"\n\nRank processed!\n". ran++.total) { tell[i-1].rank=ran.i<=n. tell[i-2].ran++.

name).j++) { print[p]=fail[j]. p++. } p--. print[i]. int p=1.j<=n.name. student print[50].j<=n. char *s.name).i<=n. strcpy(print[j]. for(int j=1. s).name.print[j]. 169 | P a g e .i++) { for(j=i+1. } } } cout<<"\t\t\tREPORT CARD\n". tell[50]. int lt=1. for(int i=1.name)>0) { strcpy(s. strcpy(print[i].name. cout<<"----------------------------------------------------------\n\n".j++) { if(strcmp(print[i]. print[j].void display() { clrscr().

cout<<sno. cout<<"Name".name)==0) { gotoxy(1. puts(count[i]. cout<<"Comp". cout<<"Tot". cout<<"Math".4). 170 | P a g e .4). count[i].4). cout<<"Chem".4).4). gotoxy(5.coord). gotoxy(69. cout<<"Eng". gotoxy(19. gotoxy(5. coord=6. cout<<"Sno". gotoxy(52. int sno=1.name). gotoxy(44. do { for(i=1. gotoxy(37.name.4).4).coord). cout<<"Rank\n\n".4).i++) { if(strcmp(print[lt].4).i<=n.gotoxy(1. cout<<"Phy". gotoxy(28. gotoxy(62.

cout<<fail[i].coord).rank==0) cout<<"-". gotoxy(44. } while(lt<=n). sno++. gotoxy(52.mark[3].coord).rank. cout<<count[i].coord). gotoxy(37. if(count[i].mark[4]. } } lt++. } void menu() { int ch. cout<<"\n\n".coord). gotoxy(68. gotoxy(62. gotoxy(28.mark[1].gotoxy(19.coord). coord+=2.coord). else cout<<count[i].coord). cout<<count[i]. p: 171 | P a g e . cout<<count[i]. cout<<count[i].total.mark[5]. cout<<count[i].mark[2].

goto p.clrscr(). cout<<"1. switch(ch) { case 1: { getdata(). cout<<"2. cout<<"4. Exit\n". Accepting student details\n". goto p. } case 3: { display(). Processing rank\n". cin>>ch. cout<<"3. Displaying the report card\n". getch(). getch(). goto p. cout<<"\nREPORT CARD GENERATION .Main Menu\n". cout<<"Enter your choice: ". getch(). } case 2: { rank(). } case 4: 172 | P a g e .

getch(). menu().{ cout<<"\nPress any key to exit. getch(). } default: { cout<<"\nWrong option! Enter again. Displaying the report card 4. } SAMPLE OUTPUT FOR THIS PROGRAM REPORT CARD GENERATION – Main Menu 1. Accepting student details 2.". } } } void main() { clrscr(). exit(0).". Exit Enter your choice: 1 173 | P a g e . goto p. Processing rank 3. getch().

: 4 Mark in English: 96 Mark in CS: 65 174 | P a g e . : 16 Mark in English: 87 Mark in CS: 69 Mark in Maths: 93 Mark in Physics: 82 Mark in Chemistry: 73 Enter details of student 2 Name: Ubanish Lahari Roll no.STUDENT DETAILS How many students? : 2 Enter details of student 1 Name: Raheem Sterling Roll no.

Accepting student details 2.Mark in Maths: 70 Mark in Physics: 62 Mark in Chemistry: 74 The entered details are Student 1 Name: Raheem Sterling Roll no. Displaying the report card 4. Exit Enter your choice: 2 Rank processed! 175 | P a g e . : 16 Student 2 Name: Ubanish Lahari Roll no. : 2 Details saved! REPORT CARD GENERATION – Main Menu 1. Processing rank 3.

Exit Enter your choice: 4 Press any key to exit. Processing rank 3. Processing rank 3.REPORT CARD GENERATION – Main Menu 1. Displaying the report card 4. Displaying the report card 4. Exit Enter your choice: 3 REPORT CARD --------------------------------------------------------Sno Name 1 2 Ubanish Lahari Raheem Sterling Eng Comp Math Phy Chem Total Rank 96 65 87 69 70 93 62 82 74 73 367 404 2 1 REPORT CARD GENERATION – Main Menu 1. Accepting student details 2. 176 | P a g e . Accepting student details 2.

Display all the details present in table SECTION1. Show the details. 177 | P a g e . NO. 4. 2. 5.EXP. Insert values as given above into the table. Create the table given. 21 DATE: 8-11-2012 SQL COMMANDS – I TABLE: Name Malvika Karan Aniket Craig Cristiano Shimoli Vignesh Roll 101 102 103 104 105 106 107 Class C12 M12 C12 C12 E12 C12 C12 Age 16 17 17 17 17 18 17 Marks 90 92 93 92 95 94 95 DOB 10-Dec-95 20-May-95 07-Aug-95 11-Jun-95 05-Oct-95 15-Nov-95 23-Sep-95 QUESTIONS: 1. 3. Display all the details of SECTION1 in descending order based on name.

11. is 107 from table SECTION1. Print minimum. Print name and roll no. 8. 9. 16. 178 | P a g e . 15. Print the sum of marks from table SECTION1. Print the atomic values of class. 7. 14. from table SECTION1 where mark is less than 93 and class is „C12‟. Delete record where roll no. Reset the values of class to M12 where roll no. Print how many classes are there. 10. maximum and average values from table SECTION1. is equal to 107. Select all the details from table SECTION1 where the name of the student starts with „S‟. Add a new attribute mark to a decimal value holder. 13. Print age and number of students in the age group 13 to 15. Modify attribute mark to a decimal value holder. 12. Print age alone in descending order. 17.6.

Display name.-------.---NAME CHAR(20) 179 | P a g e . roll no. 21. Insert data on your own. from table SECTION1 where mark of student is between 91 and 91.MARKS INTERGER. alone into this database. Create another table called SECTION3 which has details called name.AGE INTEGER. Join the two tables together such that the screen should have name and roll no. Name Null? Type --------------------------------.DOB DATE).18.ROLL NUMBER(38). Create a view called SECTION2 and copy marks and roll no. Table created. 19. Delete the SECTION1. 20. roll no. COMMANDS: SQL> CREATE TABLE SECTION1(NAME CHAR(20). SQL> DESC SECTION1. Drop the view table. 24.CLASS CHAR(10). 23. only. and class. How many marks are there in database. 22.

101. 105. 1 row created.13.‟C12‟.‟C12‟.‟15-Nov-99‟).92. SQL> INSERT INTO SECTION1 VALUES(„CRAIG‟. 1 row created.ROLL CLASS AGE MARKS DOB NUMBER(38) CHAR(10) NUMBER(38) NUMBER(38) DATE SQL> INSERT INTO SECTION1 VALUES(„MALVIKA‟.14. 103. 1 row created. 180 | P a g e . SQL> INSERT INTO SECTION1 VALUES(„KARAN‟.‟C12‟. SQL> INSERT INTO SECTION1 VALUES(„SHIMOLI‟. 102.‟M12‟.15. 1 row created.95.‟11-Jun-98‟). 1 row created.‟07-Aug-97‟).90.92.‟05-Oct-99‟).15.13. 104.‟C12‟.‟E12‟. SQL> INSERT INTO SECTION1 VALUES(„ANIKET‟.93.14. 1 row created.‟10-Dec-96‟).‟20-May-98‟).94. SQL> INSERT INTO SECTION1 VALUES(„CRISTIANO‟. 106.

13. Name Roll Class Age Marks Dob -------------------------------------------------------------Rhea 101 C12 16 90 10-Dec-95 Karan 102 M12 17 92 20-May-95 Aniket 103 C12 17 93 07-Aug-95 Craig 104 C12 17 92 11-Jun-95 Cristiano 105 E12 17 95 05-Oct-95 Shimoli 106 C12 18 94 15. 107.Nov-94 Vignesh 107 C12 17 95 23-Sep-95 7 rows selected SQL>SELECT *FROM SECTION1 ORDER BY NAME DESC Name Roll Class Age Marks Dob -------------------------------------------------------------Craig 104 C12 17 92 11-Jun-95 Vignesh 107 C12 17 95 23-Sep-95 Cristiano 105 E12 17 95 05-Oct-95 Shimoli 106 C12 18 94 15-Nov-94 Malvika 101 C12 16 90 10-Dec-95 Aniket 103 C12 17 93 07-Aug-95 Karan 102 M12 17 92 20-May-95 181 | P a g e .‟23-Sep-99‟).95. 1 row created. SQL> SELECT * FROM SECTION1.SQL> INSERT INTO SECTION1 VALUES(„VIGNESH‟.‟C12‟.

Name Roll Class Age Marks Dob -------------------------------------------------------------Cristiano 105 E12 17 95 05-Oct-95 Shimoli 106 C12 18 94 15-Nov-94 Vignesh 107 C12 17 95 23-Sep-95 SQL>SELECT AGE. MIN(MARKS) MAX(MARKS) AVG(MARKS) --------------------------------------------90 95 93 182 | P a g e . SUM(MARKS) --------------651 SQL> SELECT MIN(MARKS).7 rows selected SQL>SELECT *FROM SECTION1 WHERE NAME LIKE „S%‟.AVG(MARKS) FROM SECTION1.MAX(MARKS).COUNT(AGE) FROM SECTION1 GROUP BY AGE HAVING AGE BETWEEN 13 AND 15 AGE ----13 14 15 COUNT ---------3 2 2 SQL>SELECT SUM(MARKS) FROM SECTION1.

1 ROW UPDATE SQL>DELETE FROM SECTION1 WHERE ROLL=107. COUNT(DISTINCT CLASS) -----------------3 SQL>UPDATE SECTION1 SET CLASS=‟M12‟ WHERE ROLL=107. 1 ROW DELETED SQL>SELECT * FROM SECTION1 ORDER BY AGE DESC. Name Roll Class Age Marks Dob -------------------------------------------------------------Malvika 101 C12 16 90 10-Dec-95 Aniket 103 C12 17 93 07-Aug-95 Karan 102 M12 17 92 20-May-95 Craig 104 C12 17 92 11-Jun-95 Cristiano 105 E12 17 95 05-Oct-95 Shimoli 106 C12 18 94 15-Nov-94 6 ROWS SELECTED SQL>SELECT NAME.SQL>SELECT COUNT(DISTINCT CLASS) FROM SECTION1.ROLL FROM SECTION1 WHERE MARKS<93 AND CLASS=‟C12‟ 183 | P a g e .

CLASS -------C12 E12 M12 SQL>SELECT NAME.ROLL FROM SECTION1 WHERE MARKS BETWEEN 91 AND 94.NAME ---------MALVIKA CRAIG ROLL -------101 104 SQL>ALTER TABLE SECTION1 ADD(GAME CHAR(10)). NAME -----------KARAN ANIKET CRAIG SHIMOLI ROLL ---------102 103 104 106 SQL>SELECT COUNT(DISTINCT MARKS) FROM SECTION1. COUNT(DISTINCT MARKS) ---------------------5 184 | P a g e . TABLE ALTERED SQL>SELECT DISTINCT CLASS FROM SECTION1.

1 Row created SQL>SELECT NAME.SQL>CREATE VIEW SECTION2 AS SELECT MARKS. VIEW CREATED SQL>DROP VIEW SECTION2.ROLL NUMBER(380.ROLL FROM SECTION3 UNION SELECT NAME.CLASS CHAR(4)). TABLE CREATED SQL>INSERT INTO SECTION3 VALUES(„PAULINE‟.‟M12).ROLL FROM SECTION1. VIEW DROPPED SQL>CREATE TABLE SECTION3(NAME CHAR(10). NAME ROLL ------------------------KARAN 102 ANIKET 103 PAULINE 108 MALVIKA 101 SHIMOLI 106 CRISTIANO 105 CRAIG 104 7 Rows selected 185 | P a g e .108.ROLL FROM SECTION1.

SQL>DROP TABLE SECTION1. Table dropped 186 | P a g e .

Create the table networks. 4. 22 DATE: 22-11-2012 SQL COMMANDS – II TABLES: Table: Interiors NO 1 2 3 ITEMNAME SLEEPWELL SHISHI PRINCESS TYPE DATEOFSTOCK PRICE DISCOUNT DOUBLE BED 23-FEB-02 32000 15 BABY COT 20-JAN-02 9000 10 BABY COT 19-JAN-02 8500 10 Table: Newones NO 1 2 3 ITEMNAME KING SIZE RECLINER JINGLE TYPE DATEOFSTOCK PRICE DISCOUNT DOUBLE BED 23-MAR-03 20000 20 SOFA 20-FEB-03 15000 15 BABY COT 21-FEB-03 7000 10 QUESTIONS: 1. 187 | P a g e . Create the table interiors.EXP. NO. 2. 3. Insert values into interiors table. Display contents of table interiors.

in which the discount percentage is more than 15 from interiors table. 9.whose type is double bed from interiors table. To list itemname and type of those items in which date of stock is before 22-01-2002 from the interiors table in descending order of itemname. COMMANDS: SQL>CREATE TABLE INTERIORS (NO INTEGER. To display itemname and date of stock of those items . 12. Insert values into newones table. 15000. To count the number of items .20. 7. 6.‟india teak‟ . ‟28-MAR-03‟. To show all information about the sofas from the interiors table. 8. Display the contents of table newones. To insert a new row in the newones table with the following data: 14. 188 | P a g e . 10. 11.5. To list the itemnames and which are priced at more than 10000 from the interiors table.‟office table‟ .

SQL>INSERT INTO INTERIORS VALUES(1.‟PRINCESS‟.-----------------.‟23-FEB-02‟.15).---------.10). NO ITEMNAME TYPE DATEOFSTOCK PRICE DISCOUNT -.‟SHISHI ‟. Table created.ITEMNAME CHAR(15). TYPE CHAR(15).-----------------1 SLEEPWELL DOUBLE BED 23-FEB-02 32000 15 2 SHISHI BABY COT 20-JAN-02 9000 10 3 PRINCESS BABY COT 19-FEB-02 8500 10 SQL> CREATE TABLE NEWONES 2 (NO INTEGER.‟20-JAN-02‟. 1 row created SQL>INSERT INTO INTERIORS VALUES(2. ‟BABY COT‟ . ‟BABY COT‟ .‟SLEEPWELL‟.10).-----------. ‟DOUBLE BED‟ .--------------. 189 | P a g e . 1 row created SQL>SELECT* FROM INTERIORS. 32000. 9000. 8500. DISCOUNT INTEGER). PRICE INTEGER.‟19-FEB-02‟. 1 row created SQL>INSERT INTO INTERIORS VALUES(3. DATEOFSTOCK DATE.

DATEOFSTOCK DATE.3 4 5 6 7 ITEMNAME CHAR(15). SQL> INSERT INTO NEWONES VALUES(12.'RECLINER'.------------------11 KING SIZE DOUBLE BED 23-MAR-03 20000 20 12 RECLINER SOFA 20-FEB-03 15000 15 13 JINGLE BABY COT 21-FEB-03 7000 10 190 | P a g e .15 1 row created. SQL> INSERT INTO NEWONES VALUES(13. NO ITEMNAME TYPE DATEOFSTOCK PRICE DISCOUNT --------.'SOFA'.--------. TYPE CHAR(15).'BABY COT'.--------. SQL> SELECT*FROM NEWONES.'21-FEB-03'. 1 row created. 1 row created. SQL> INSERT INTO NEWONES VALUES(11. Table created.'KING SIZE'. DISCOUNT INTEGER).'DOUBLE BED'.'23-MAR-03'.--------------.'20-FEB-03'. PRICE INTEGER.15000.'JINGLE'.--------------.7000.

'INDIA TEAK'. no rows selected SQL> SELECT ITEMNAME FROM INTERIORS WHERE PRICE>10000.'28-MAR-03'.15000. ITEMNAME --------------SLEEPWELL SQL> SELECT ITEMNAME FROM INTERIORS WHERE DATEOFSTOCK<'22-JAN-02'ORDER BY ITEMNAME DESC. 1 row created.'OFFICE TABLE'. ITEMNAME --------------SHISHI SQL> SELECT COUNT(*)FROM INTERIORS WHERE TYPE='DOUBLE BED'.SQL> SELECT*FROM INTERIORS WHERE TYPE='SOFA'.20). COUNT(*) --------1 SQL> INSERT INTO NEWONES VALUES(14. 191 | P a g e .

192 | P a g e .