Computer Practical

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 129

PROGRAM-1

Program to find the largest number amongst three numbers .

#include<iostream.h>
int main() { int x,y,z,max; cout<<"Enter three numbers :"; cin>>x>>y>>z; max= x; if(y>max) max=y; if(z>max) max=z; cout<<"\n"<<"The largest of"<<x<<","<<y<<","<<z<<"is"; cout<<max; return 0; }

OUTPUT:------

Enter three numbers :4 5 6 The largest of 4, 5, 6is6

PROGRAM-3

Program to print the sum of series 1+1/2!+1/3!+1/4!.........upto N terms.

#include<iostream.h> void main() { float a,n,s=0,f,b; cout<<"Enter the last value :"; cin>>n; for(a=1;a<=n;a++) { for(f=1,b=a;b>=1;b--) f=f*b; cout<<1/f<<"+"; s=s+1/f; } cout<<"\b\b="<<s; }

OUTPUT:------

Enter the last value :4 1+0.5+0.166667+0.41666=1.70833

PROGRAM-5

Program to input a number and check whether the number is perfect or not.

#include<iostream.h> void main() { int n,s,a; cout<<"Enter a number :-"<<endl; cin>>n; for(a=1,s=0;a<n;a=a+1) { if(n%a==0) s=s+a; } if(s==n) cout<<"This is a perfect number"<<endl; else cout<<"This is not a perfect number"; }

OUTPUT:------Enter a number : 6 This is a perfect number

PROGRAM-8

Program to input a number and check whether the number is a magic number or not.

#include<iostream.h> void main() { int num,num1,i,j,k,flag=0,n,sum=0,c=0; cout<<"Enter any number :-"; cin>>num; num1=num; while(flag==0) { while(num!=0) { n=num%10; sum=sum+n; num=num/10; c=c+1; } if(c==1) { if(sum==1) cout<<num1<<"is a magic number"; else cout<<num1<<"is not a magic number"; flag=1; } num=sum; sum=0;

c=0; } }

OUTPUT:-----Enter any number :-154 154is a magic number

PROGRAM-9

Program to perform various operations on string, menu drivel without using language supported built in function. i) Find the length of the string. ii) Reverse the string. iii) Copy the string. iv) To concatenate the string.

#include<iostream.h> #include<string.h> #include<stdio.h> class strn { char a[20],arr[20],A[20]; int i,j,k; public: void read(); //MEMBER FUNCTION void rev(); void copy(); void merge(); void display(); }; void strn::read() { gets(a); //TO READ THE STRING } void strn::rev() { int l=strlen(a); int j=0; for(i=l-1;i>=0;i--) { arr[j]=a[i]; j++;

} arr[i]='\0'; cout<<"\nReverse string :------"; for(i=0;arr[i]!='\0';i++) cout<<arr[i]; } //To Find The Reverse Of The String

void strn::copy() { cout<<"\n\tThe entered string was :------"; puts(a); for(i=0;a[i]!='\0';i++) A[i]=a[i]; A[i]='\0'; cout<<"\nCopied string :-----"; //To Find The Copy Of The String for(i=0;A[i]!='\0';i++) cout<<A[i]; } void strn::merge() { char c[40]; cout<<"\n\t"; for(i=0;a[i]!='\0';i++) c[i]=a[i]; int k=i; for(i=0;arr[i]!='\0';i++) { c[k]=arr[i]; k++; } c[k]='\0'; cout<<"\n\tConcatenate String is :-----"; //To Find The Concatenate Of The

// String for(i=0;c[i]!='\0';i++) cout<<c[i]; } void strn::display() { puts(a); } void main() { strn x; //DECLERATION OF OBJECT cout<<"\nEnter the string :-----"; x.read(); //CALLING MEMBER FUNCTION x.rev(); x.copy(); x.merge(); cout<<"\n\n\t\tbye!"; }

OUTPUT:------Enter the string :------flower Reverse string :------rewolf The entered string was :-----flower Copied string :-------flower Concatenate string is :-------flowerrewolf bye!

PROGRAM-2

Program to print the armstrong number between 1 to 500.

#include<iostream.h> void main() { int a,i,r,w; cout<<"\nThe Armstrong numbers are :-\n"; for(i=1;i<=500;i++) { a=i;w=0; while(a>0) { r=a%10; w=w+(r*r*r); a=a/10; } if(w==i) cout<<i<<" "; } }

OUTPUT:------The Armstrong numbers are :1 153 370 371 401

PROGRAM-4

Program to print the prime factorization of a number.

#include<iostream.h> #include<stdio.h> void main() { int n,i,j,c; cout<<"\nEnter a number :-"; cin>>n; cout<<"\nPrime factors are :-"; for(i=1;i<n;i++) { c=0; if((n%i==0)&&(i!=1)) { for(j=2;j<i;j++) { if(i%j==0) { c=1; break; } } if(c==0) cout<<i<<" "; } } }

OUTPUT:-------Enter a number :20 Prime factors are :2 5

PROGRAM-6

Program to print the prime fibonacci series within the range of 1 to 1000.

#include<iostream.h> void main() { int a=1,b=1,c,j,i,s; cout<<"Prime fibonacci series is :-\n"; cout<<a<<" "<<b<<" "; for(i=3;i<=20;i++) { c=a+b; s=0; for(j=2;j<c;j++) { if(c%j==0) { s=1; break; } } if(s==0) cout<<c<<" "; a=b; b=c; } }

OUTPUT:-------Prime fibonacci series is :1 1 2 3 5 13 89 233 1597

PROGRAM-7

Program to print the Pascals triangle.

#include<iostream.h> void main() { int i,j,k,n,pal[50][50]; cout<<"\nEnter the number of rows :-"; cin>>n; for(i=0;i<n;i++) { pal[i][0]=1; pal[i][i]=1; for(j=1;j<i;pal[i][j]=pal[i-1][j-1]+pal[i-1][j],j++); for(j=1;j<=(n-(i+1));cout<<" ",k++); cout<<"\n"; } }

OUTPUT:--------1 11 121 1331 14641 15 10 10 5 1 1 6 15 20 15 6 1 1 7 21 35 35 21 7 1 1 8 28 56 70 56 28 81 1 9 36 84 126 126 84 36 9 1

PROGRAM-10

Program to create a string & display the character from even, odd, & prime position.

#include<iostream.h> void main() { char str[50],odd[50],even[50],prime[50]; int i,j,a,b,c; a=b=c=0; cout<<"\nEnter a string(maximum 50 characters):-"; cin.getline(str,20); for(i=0;str[i]!='\0';i++) { if(i%2==0) even[a++]=str[i+1]; else if(i%2!=0) odd[b++]=str[i-1]; } for(i=1;str[i]!='\0';i++) { int flg=0; for(j=2;j<i;j++) { if((i+1)%j==0) { flg=1; break; } } if(flg==0) prime[c++]=str[i]; } cout<<"\nCharacter(s) at:--"; cout<<"\n\nPrime Position:--"; for(i=0;i<a;cout<<prime[i++]<<" "); cout<<"\n\nEven Position:--"; for(i=0;i<b;cout<<even[i++]<<" "); cout<<"\n\nOdd Position:--"; for(i=0;i<c;cout<<odd[i++]<<" "); }

OUTPUT:--------Enter a string(maximum 50 characters) :- SAUGATO Character(s) at :-Prime Position :-- A U A O Even Position :-- A G T Odd Position :-- S U A

PROGRAM-11

Program to store the information of five employees and to display the information of an employee depending upon the Employee number given (Structure Implementation).

#include<iostream.h> #include<stdio.h> struct emp { char nm[30]; char design[30]; char add[50]; int empno; float basic; } worker; emp sales_emp[10]; void enter(); void display(int a); void main() { int eno,i;char ch='y'; cout<<"\nEnter employee details :---\n"; enter(); while(ch=='y'||ch=='y') { cout<<"\nEnter employee number whose information is to be displayed:---"; cin>>eno; int c=0; for(i=0;i<5;i++) { if(sales_emp[i].empno==eno) { display(i); c=1; break; } } if(c==0) cout<<"\nNo information of such employee is present...\n"; cout<<"\nDisplay more????";

ch=getchar(); } } void enter() { for(int i=0;i<5;i++) { cout<<"\n Enter the details of the employee"<<(i+1)<<":--"; cout<<"\nEmployee number :--"; cin>>sales_emp[i].empno; cout<<"Employee name:--"; gets(sales_emp[i].nm); cout<<"Enter the designation :--"; gets(sales_emp[i].design); cout<<"Enter the address :--"; gets(sales_emp[i].add); cout<<"Enter the basic salary :--"; cin>>sales_emp[i].basic; } return; } void display(int a) { cout<<"\nEmployee Data:--\n"; cout<<"\nEmployee no. :--"<<sales_emp[a].empno; cout<<"\nName :--"<<puts(sales_emp[a].nm); cout<<"\nDesignation :--"<<puts(sales_emp[a].design); cout<<"\nAddress :--"<<puts(sales_emp[a].add); cout<<"\nBasic Pay :--Rs "<<sales_emp[a].basic; return; }

OUTPUT:-------Enter the details of employee 1 :-Employee number :--1 Employee name:--Sukhdev Singh Enter the designation :--A Enter the address :--29/a,delhi Enter the basic salary :--5000 Enter the details of the employee 2 Employee number :--2 Employee name:--ravi jha Enter the designation :--b Enter the address :--29/a,Mumbai Enter the basic salary :--15000 Enter the details of the employee 3 Employee number :--3 Employee name:--rohit singh Enter the designation :--c Enter the address :--29/a,kolkata Enter the basic salary :--20000 Enter the details of the employee 4 Employee number :--4 Employee name:--susmita agarwal Enter the designation :--d Enter the address :--27/b,jammu Enter the basic salary :--5000 Enter the details of the employee 5 Employee number :--5 Employee name:--neha gupta Enter the designation :--p Enter the address :--pp,kolkata Enter the basic salary :--35000 Enter employee number whose information is to be displayed:--Employee number :--5 Employee Data:-Employee number :--5

Employee name:--neha gupta Enter the designation :--p Enter the address :--pp,kolkata Enter the basic salary :--35000 Display more????

PROGRAM-12

Program to create a Magic Square Box of order nxn (The speciality of a magic square box Is that the sum of element of any row or column is always equal).

#include<iostream.h> #include<math.h> #include<stdlib.h> #include<alloc.h> int arr[10][10],n,a,b,i; void magic(int,int,int,int); void main() { int j,x,k; cout<<"\nEnter the size of matrix nxn where n is odd:"; cin>>n; cout<<"\nEnter !st element of the %d sequential elements"; cin>>x; for(i=0;i<n;i++) { for(k=0;k<n;k++) { arr[i][k]=-1; } } arr[0][n/2]=x; magic(0,n/2,x,n); cout<<"\n"; for(i=0;i<n;i++) { for(k=0;k<n;k++) { for(k=0;k<n;k++) { cout<<arr[i][j]; } cout<<"\n"; } }

void magic(int a,int b,int x,int n) { int c; c=1; for(x=x+1;i<=nxn;i++,c++,x++) { if(c<n); { a=a-1; b=b-1; if(a==-1) a=n-1; if(b==-1) b=n-1; } else; { a=a+1; c=0; } arr[a][b]=x; } }

OUTPUT:Enter the size of matrix(nxn,where n is odd : 7 Enter 1st element of the 49 sequential elements: 6

33 24 15 34 32 23 42 40 31 50 41 39 9 49 47 17 8 48 25 16 7

6 53 44 35 14 12 52 43 22 13 11 51 30 21 19 10 38 29 20 28 46 37 28 26 54 45 36 27

PROGRAM-24

Program to Implement Push and Pop Operation in a Stack of Array.

#include<iostream.h> #include<stdio.h> #include<stdlib> #include<ctype.h> #define MAX 20 //Show maximum array length int queue[MAX]; //Declares array global variable int top; //Declares integer top void push(int stack[], int val, int &top); //Add stack int pop(int stack[], int &top); //Delete Stack void show_Stack(int stack[], int top); //Show stack void main() { int choice; int val; char opt=Y; top=-1; //Initialization of Stack do { cout<<\n\t\t Main Menu; cout<<\n\t1. Addition of Queue; cout<<\n\t2. Deletion from Queue cout<<\n\t3. Traverse of Queue; cout<<\n\t4. Exit from Menu; cout<<\n\nEnter your choice from above; cin>>choice; switch (choice) { case 1: do { cout<<Enter the value to be added in the Stack; cin>>val; push(stack, val, top); cout<<\nDo you want to add more elements <Y/N>?; } }

//Function body for delete stack with array int pop(int stack[], int &top) { int value; if(top<0) { cout<<Stack Empty; value=-1; } else { value=stack[top]; top=top-1; } return(value); } //Function body for show stack with array void show_Stack(int stack[], int top) { int I; I = top; cout<<The values are; do { cout<<\n<<stack[i]; i = i-1l; } while(i>=0); }

OUTPUT :--------

Main Menu 1. Additional of Stack 2. Deletion from Stack 3. Traverse of Stack 4. Exit from Menu Enter your choice from above 1 Enter the value to be added in the queue 5 Do you want to add more element <Y/N>? Y Enter the value to be added in the Stack 6 Do you want to add more elements <Y/N>? Y Enter the value to be added in the Stack 8 Do you want to add more elements <Y/N>? Main Menu 1. Additional of queue 2. Deletion from Queue 3. Traverse of Queue 4. Exit from Menu Enter your choice from above 3 The values are 8 6 5 Main Menu 1. Additional of queue 2. Deletion from Queue 3. Traverse of Queue 4. Exit from Menu

Enter your choice from above 2 Value deleted from queue is 8 Do you want to delete more element <Y/N>? N Main Menu 1. Additional of queue 2. Deletion from Queue 3. Traverse of Queue 4. Exit from Menu Enter your choice from above 4.

PROGRAM-25

Program to create Linear Stack of Integers and implement Push and Pop Operations on it.

#include<iostream.h> #include<stdio.h> #include<stdlib> #include<ctype.h> struct node { int data; node*link; }; node*push(node*top, int val); //Add stack node*pop(node*top, int &val); //Delete stack void show_Stack(node*top); //Show stack void main() { node*top; int val; int choice; char opy=Y; top=NULL; //Initialization of stack do { cout<<\n\t\t Main Menu; cout<<\n\t1. Addition of Stack; cout<<\n\t2. Deletion from Stack cout<<\n\t3. Traverse of Stack; cout<<\n\t4. Exit from Menu; cout<<\n\nEnter your choice from above; cin>>choice; switch (choice) { case 1: do { cout<<Enter the value to be added in the stack; cin>>val;

top=push(top, val); cout<<\nDo you want to add more elements <Y/N>?; cin>>opt; } while(toupper(opt)==Y); break; case 2: opt=Y; do { top=pop(top, val); if(val!=-1) cout<<Value deleted from Stack is<<val; cout<<\nDo you want to delete more element <Y/N>?; cin>>opt; } while(toupper(opt)==Y); break; case 3: show_Stack(top); break; case 4: exit(0); } } while(choice!=4); } //Function body for add stack element node*push(node*top, int val) { node*temp; temp=new node; temp->data=val; temp->link=NULL;

if(top==NULL) top=temp; else { temp->link=top; top=temp; } } //Function body for delete stack elements node*pop(node*top, int &val) { node*temp; if(top==NULL) { cout<<Stack Empty; val=-1; } else { temp=top; top=top->link; val=temp->data; temp->link=NULL; delete temp; } return(top); } //Function body to show stack elements void show_Stack(node*top) { node*temp; temp=top; cout<<The value are \n; while(temp!=NULL) { cout<<\n<<temp->data; temp=temp->link;

} } OUTPUT:-----------

Main Menu 1. Additional of Stack 2. Deletion from Stack 3. Traverse of Stack 4. Exit from Menu Enter your choice from above 1 Enter the value to be added in the stack 4 Do you want to add more elements <Y/N>? Y Enter the value to be added in the stack 7 Do you want to add more elements <Y/N? Y Enter the value to be added in the stack 5 Do you want to add more elements <Y/N? N Main Menu 1. Additional of Stack 2. Deletion from Stack 3. Traverse of Stack 4. Exit from Menu Enter your choice from above 3 The value are 5 7 4 Main Menu 1. Additional of Stack 2. Deletion from Stack

3. Traverse of Stack 4. Exit from Menu

Enter your choice from above 2 Value deleted from Stack is 5 Do you want to delete more elements <Y/N> ? N Main Menu 1. Additional of Stack 2. Deletion from Stack 3. Traverse of Stack 4. Exit from Menu Enter your choice from above 3 The values are 7 4 Main Menu 1. Additional of Stack 2. Deletion from Stack 3. Traverse of Stack 4. Exit from Menu Enter your choice from above 4

PROGRAM-26

Program to create Linear Circular Queue and to perform Additional and Deletion on the Queue.

#include<iostream.h> #include<stdio.h> #include<stdlib> #include<ctype.h> #define MAX 20 //Show maximum array length int queue[MAX]; //Declares array global variable int front, rear; //declares integer front and read void add_Q(int queue[], int front, int val, int &rear); int del_Q(int queue[], int &front, int rear); void show_Q(int queue[], int front, int rear); void main() { int choice; int val; char opt = Y; rear = -1; // Initialization of Queue front = -1; clrscr(); do { cout<<\n\t\t Main Menu; cout<<\n\t1. Addition of Queue; cout<<\n\t2. Deletion from Queue cout<<\n\t3. Traverse of Queue; cout<<\n\t4. Exit from Menu; cout<<\n\nEnter your choice from above; cin>>choice; switch (choice) { case 1: do { cout<<Enter the value to be added in the Queue;

cin>>val; add_Q(queue, front, val, rear); cout<<Do you want to add more element <Y/N>?; opt=getchar(); } while(opt==Y||opt==y); break; case 2: opt=Y; do { val=del_Q(queue, front, rear); if(val !=-1) cout<<Value deleted from Queue is <<val; cout<<\n Do you want to delete more element <Y/N>?; opt=getchar(); } while(opt==Y||opt==y); getch(); break; case 3: show_Q(queue, front, rear); getch(); break; case 4: exit(0); } } While (choice>=1&&choice<=4); } // Function body to add circular queue with array of character void add_Q(int queue[], int front, int val, int &rear) { if ((rear + 1) % MAX == front)

{ cout<<Queue Full; } else { rear=(rear+1)%MAX; queue[rear]=val; } } //Function body to delete circular queue with array of character int del_Q(int queue[], int front, int val, int&rear) { int value; if(front==red) { cout<<Queue Empty; value=-1; } else { front=(front+1)%MAX; value=queue[front]; } return(value); } // Function body to show circular queue with array void show_Q(int queue[], int front, int rear); { cout<<The values are; do { front=(front+1)%MAX; cout<<\n<<queue[front]; } while(front!=rear); }

OUTPUT:--------Main Menu 5. Additional of queue 6. Deletion from Queue 7. Traverse of Queue 8. Exit from Menu Enter your choice from above 1 Enter the value to be added in the queue 4 Do you want to add more element <Y/N>? Y Enter the value to be added in the queue 7 Do you want to add more elements <Y/N>? N Main Menu 5. Additional of queue 6. Deletion from Queue 7. Traverse of Queue 8. Exit from Menu Enter your choice from above 3 The values are 4 7 Main Menu 5. Additional of queue 6. Deletion from Queue 7. Traverse of Queue 8. Exit from Menu Enter your choice from above 2 Value deleted from queue is 4 Do you want to delete more element <Y/N>? N Main Menu 5. Additional of queue 6. Deletion from Queue

7. Traverse of Queue 8. Exit from Menu Enter your choice from above 4.

PROGRAM-27

Program to create Linear Stack containing Roll number and Age and to perform Addition and deletion on it.

#include<iostream.h> #include<stdio.h> #include<stdlib.h> #include<ctype.h> // Declares a stack structure struct node. { int roll; int age; node*link; }; // Function prototype deceleration for add stack, delete stack, and show stack. node*push(node*top, int val, int tage); node*pop(node*top); void show_Stack(node*top); //Main programming logic void main() { node*top; int troll, tage, choice; char opt=Y; top=NULL; clrscr(); do { cout<<\n\t\t Main Menu; cout<<\n\t1. Addition of Stack; cout<<\n\t2. Deletion from Stack cout<<\n\t3. Traverse of Stack; cout<<\n\t4. Exit from Menu; cout<<\n\nEnter your choice from above; cin>>choice; switch (choice)

{ case 1: do { cout<<Enter the roll no. :; cin>>troll; cout<<Enter age; cin>>tage; top=push(top, troll, tage); cout<<\nDo you want to delete more elements <Y/N> ?; cin>>opt; } while(toupper(opt)==Y); break; case 2: opt=Y; do { top=pop(top); if(troll!=-1) cout<<\nValue deleted from Stack is <<troll; cout<<\nDo you want to delete more elements <Y/N> ?; cin>>opt; } while(toupper(opt)==Y); break; case 3: show_Stack(top); braek; case 4: exit(0); } } while(choice!=4);

} // Function body for add stack elements node*push(node*top, int val, int tage) { node*temp; temp=new node; temp->roll=val; temp->link=NULL; if(top==NULL) top=temp; else { temp->link=top; top=tamp; } return(top); } // Function body for delete stack elements node*pop(node*top) { node*temp; int tage, troll; if(top==NULL) { cout<<Stack Empty; troll=-1; } else { temp=top; top=top->link; troll=temp->age; temp->link=NULL; cout<<\n\tPopped Roll Number is :<<temp->roll; cout<<\n\tPopped Age is :<<<<temp->age; delete temp; }

return(top); } // Function body for show stack elements void show_Stack(node*top) { node*temp; temp=top; cout<<The values are \n; while(temp!=NULL) { cout<<\n<<temp->roll<<\t<<temp->age; temp=temp->link; } }

OUTPUT :-----------

Main Menu 5. Additional of Stack 6. Deletion from Stack 7. Traverse of Stack 8. Exit from Menu Enter your choice from above 1 Enter the roll no. : 5 Enter age : 18 Do you want to add more elements <Y/N>? Y Enter the roll no. : 10 Enter age : 20 Do you want to add more elements <Y/N? N Main Menu 5. Additional of Stack 6. Deletion from Stack 7. Traverse of Stack 8. Exit from Menu Enter your choice from above 3 The value are 10 20 5 18 Main Menu 5. Additional of Stack 6. Deletion from Stack 7. Traverse of Stack 8. Exit from Menu

Enter your choice from above 2 Popped Roll Number is : 10 Popped Age is : 20 Value deleted from Stack is 10 Do you want to delete more elements <Y/N> ? N Main Menu 5. Additional of Stack 6. Deletion from Stack 7. Traverse of Stack 8. Exit from Menu Enter your choice from above 4

PROGRAM-28

Program to create Linear Queue containing Employee number add Salary and to perform addition and deletion on it.

#include<iostream.h> #include<stdio.h> #include<stdlib.h> #include<ctype.h> struct node { int Eno; float Salary; node*link; }; node*add_Q(node*rear, int val, float val1); node*del_Q(node*front, int &val, float&val1); void show_Q(node*front); void main() { node*front,*rear; int val; float val1; int choice; char opt=Y; // To continue the do loop in case front=rear=NULL; // Initializing of queue do { cout<<\n\t\t Main Menu; cout<<\n\t1. Addition of Queue; cout<<\n\t2. Deletion from Queue cout<<\n\t3. Traverse of Queue; cout<<\n\t4. Exit from Menu; cout<<\n\nEnter your choice from above; cin>>choice; switch (choice) { case 1: do { cout<<Enter value to be added in the Queue cin>>val;

cin<<val1; rear=add_Q(rear, val, val1); if(front==NULL) front=rear; cout<<Do you want to add more elements <Y/N>?; cin>>opt; } while(toupper(opt)==Y; break; case 2: opt=Y; //Initialize for the second loop do { front=del_Q(front, val, val1); if(front==NULL) rear=front; if(val!=-1) cout<<value deleted from Queue is<< val; cout<<Do you want to delete more element <Y/N>?; cin>>opt; } while(toupper(opt)==Y); break; case 3: show_Q(front); break; case 4: exit(0); } } while(choice!=4); } // Function body to add queue elements node*add_Q(node*rear, int val, float val1)

{ node*temp; temp=new node; temp->Eno=val; temp->Salary=val1; temp->link=temp; rear= temp; return(rear); } // Function body to delete queue elements node*del_Q(node*front, int &val, float&val1) { node*temp; if(front==NULL) { cout<<Queue Empty; val=-1; } else { temp=front; front=front->link; val=temp->Eno; val=temp->Salary; temp->link=NULL; delete temp; } return(front); } // Function body to show queue elements void show_Q(node*front) { node*temp; temp=front; cout<<The queue values are; while(temp!=NULL) {

cout<<\nENO :<<temp->Eno; cout<<\nSalary :<<temp->Salary; temp=temp->link; } }

OUTPUT :-------------Main Menu 1. Additional of queue 2. Deletion from Queue 3. Traverse of Queue 4. Exit from Menu Enter your choice from above 1 Enter your choice to be added in the queue 5 7000 Do you want to add more element <Y/N>? Y Enter the value to be added in the queue 8 9000 Do you want to add more elements <Y/N>? N Main Menu 1. Additional of queue 2. Deletion from Queue 3. Traverse of Queue 4. Exit from Menu Enter your choice from above 3 The Queue values are ENO : 5 Salary : 9000 Main Menu 1. Additional of queue 2. Deletion from Queue 3. Traverse of Queue 4. Exit from Menu Enter your choice from above 2 Value deleted from Queue is 5

Do you want to delete more elements <Y/N>? N Main Menu 1. Additional of queue 2. Deletion from Queue 3. Traverse of Queue 4. Exit from Menu Enter your choice from above 4

PROGRAM-29

Program to Implement Insertion and Deletion in a circular Array Queue.

#include<iostream.h> #include<stdio.h> #include<stdlib.h> #include<ctype.h> #include MAX 20 //Shows maximum array length char queue[MAX]; //Declares array global variable int front, rear; //Declares integer front and read //Function prototype to add queue, delete queue and show queue in array //implementation void add_Q(char queue[], int front, char val, int &rear); //Add queue char del_Q(char queue[], int front, int rear); //delete queue void show_Q(char queue[], int front, int rear); //Show queue void main() { int choice; char val; char opt=Y; //To continue the do loop in case rear=-1; //Initialization of queue front=-1; clrscr(); do { cout<<\n\t\t Main Menu; cout<<\n\t1. Addition of Queue; cout<<\n\t2. Deletion from Queue cout<<\n\t3. Traverse of Queue; cout<<\n\t4. Exit from Menu; cout<<\n\nEnter your choice from above; cin>>choice; switch (choice) { case 1: do { cout<<Enter the value to be added in the Queue; cin>>val; add_Q(queue, front, val, rear);

cout<<Do you want to add more element <Y/N>?; cin>>opt; } while(toupper(opt)==Y); break; case 2: opt=Y //Initializing for second loop do { val=del_Q(queue, front, rear); if(val!=-1) cout<<Value deleted from queue is<<val; cout<<\nDo you want to delete more elements <Y/N>?; cin>>opt; } while(toupper(opt)==Y); break; case 3: show_Q(queue, front, rear); break; case 4: exit(0); } } while(choice!=4); } // Function body to add circular queue with array of character void add_Q(char queue[], int front, int val, int &rear) { if((rear+1)%MAX==front) { cout<<Queue Full; } else

{ rear=(rear+1)%MAX; queue[rear]=val; } } //Function body to delete circular queue with array of character char del_Q(char queue[], int &front, int rear) { char value; if(front==rear) { cout<<Queue Empty; value=-1; } else { front=(front+1)%MAX; value=queue[front]; } } //Function body to show circular queue with array void show_Q(char queue[], int front, int rear) { clrscr(); cout<<The values are; do { front=(front+1)%MAX; cout<<\n<<queue[front]; } while(front!=rear); }

OUTPUT :-----------Main Menu 1. Additional of queue 2. Deletion from Queue 3. Traverse of Queue 4. Exit from Menu Enter your choice from above 1 Enter the value to be added in the queue 5 Do you want to add more element <Y/N>? Y Enter the value to be added in the queue 7 Do you want to add more elements <Y/N>? Y Enter the value to be added in the queue 3 Do you want to add more elements <Y/N>? N Main Menu 1. Additional of queue 2. Deletion from Queue 3. Traverse of Queue 4. Exit from Menu Enter your choice from above 3 The values are 5 7 3 Main Menu 1. Additional of queue 2. Deletion from Queue 3. Traverse of Queue 4. Exit from Menu Enter your choice from above 2 Value deleted from queue is 5 Do you want to delete more element <Y/N>? N

Main Menu 9. Additional of queue 10. Deletion from Queue 11. Traverse of Queue 12. Exit from Menu Enter your choice from above 4.

PROGRAM-22

Program to create a Text File to read and display Uppercase and Lowercase Vowels and Consonants.

#include<iostream.h> #include<fstream.h> #include<stdio.h> #include<ctype.h> #include<process.h> void main() { clrscr(); int n,j; ifstream fin; ofstream fout; char str[100]; char ch,ch1; do { cout<<\n\t1.Create Text\n\t3.create another file; cin>>ch; switch(ch) { case `1`: fout.open(smp.txt); cout<<\n Enter The Text; gets(str); fout<<str; fout.close(); break; case `2`: char tmp1; fin.open(smp.txt); while(!fin.eof()) { fin.get(tmp1); if(tmp1>=`a`&&tmp1<=`z`) {

if(tmp1>=`a`||tmp1==`e`||tmp1==`i`||tmp1==`o`||tmp1==`u`) cout<<\n Lower case vowel<<tmp1; else cout<<\n Lower case constants<<tmp1; } if(tmp1>=`A~&&tmp1<=`Z`) { if(tmp1>=`A`||tmp1==`E`||tmp1==`I`||tmp1==`0`||tmp1==`U`) cout<<\n Upper case vowel<<tmp1; else cout<<\n Upper case constants<<tmp1; } } fin.close(); break; case `3`: fin.open(smp.txt); fout.open(smp1.txt); char c; while(!fin.eof()) { fin.get(c); c=tolower(c); if(c==`a`||c==`i`==||c==`e`||c==`o`||c==`u`) fout.put(c); } fin.close(); fout.close(); case `4`:exit(0); } cout<<\n\tDO U want to continue; cin>>ch1; } while(ch1==`y`||ch1==`y`); getch(); }

OUTPUT:----

1.Create Text 2.Read from file 3.Create another file 4.Exit 1 Enter The Text Friendz For Ever DO U w1.Create Text 2.Read from file 3.Create another file 4.Exit 2 Upper case consonants F Lower case consonants r Lower case vowel i Lower case vowel e Lower case consonants n Lower case consonants d Lower case consonants z Upper case consonants F Lower case vowel o Lower case consonants r Upper case vowel E Lower case consonants v Lower case vowel e Lower case consonants r D U want to continue n

PROGRAM-23

Program to Implement various File Operations,

#include<iostream.h> #include<fstream.h> #include<stdio.h> #include<process.h> #include<string.h> Class student { char nm[30]; int roll,marks; public: void getdata() { Cout<<\nenter your roll number:---; Cin>>roll; Cout<<\nEnter your name:---; Gets(nm); Cout<<\nEnter your total marks:---; Cin>>marks; } Void disp() { Cout<<\nROLL NO:---<<roll; Cout<<\nNAME:---; Puts(nm); Cout<<\nTOTAL MARKS:--<<marks; } Void modify() { Char n[30]; Int m,r; Cout<<\nEnter new roll number:--; Cin>>r; cout<<\nEnter the new name:--; gets(n);

cout<<\nEnter the new total marks:--; cin>>m; for(int i=0;n[i]!=\o;i++) nm[i]=n[i]; marks=m;roll=r; } Int getrno() { Return roll; } }; Void main() { Student stud,s1,s2; Ofstream fout;ifstream fin; Int i,f=0,rn,ch,pos; Char c=y,confirm; Fout.open(student.txt); For(i=0;i<2;i++) { Cout<<\nEnter the details of student<<(i+1)<<:--\n; Stud.getdata(); Fout.write((char*)&stud,sizeod(stud)); } Fout.closed(); While(c==y||c==Y) { Cout<<\nMENU; Cout<<\n1.Search for a record; Cout<<\n2.Insert a new record; Cout<<\n3.Delete a record; Cout<<\n4.Modify a record; Cout<<\n5.EXIT; Cout<<\nEnter your choise:---; Cin>>ch; Switch(ch) {

Case 1: Fin.open(student.txt); Cout<<\nEnter roll no to be searched for:--; Cin>>rn; While(fin!=NULL) { Fin.read((char*)&s1,sizeof(s1)); If(s1.disp()); F=1; Break; if(f==0) Cout<<\nRoll number not found!!!!<<endl; Fin.close(); Break; Case2: Fin.open(student.txt); Fout.open(temp.txt); Cout<<\nEnter the details of student whose record is to be inserted:----\n; s2.getdata(); while(fin.read((char*)&s1,sizeof(s1))!=NULL) { If(s2.getrno()<=s1.getrno()) { Fout.write((char*)&s2,sizeof(s2)); F=1; Break; }else Fout.write((char*)&s2,sizeof(s1)); } If(f==0) Fout.write((char*)&s2,sizeof(s2)); Else { fout.write((char*)&s1,sizeof(s1)); While(fin.read((char*)&s1,sizeof(s1))!=NULL) { fout.write((char*)&s1,sizeof(s1)); } }

} } Fin.close();fout.close(); Remove(student.txt); Rename(temp.txt,student.txt); Fin.open(student.txt); Cout<<\nFile now contains:---\n\n; While(fin.read((char*)&s1,size of(s1))!=NULL) { S1.disp(); } Fin.close(); Break; Case 3: Fin.open(student.txt); Fout.open(tmp.txt); Cout<<\nEnter the roll number of student whose record is to be deleted:---; Cin>>rn; While(fin.read((char*)&s1,sizeof(s1))!=NULL) { If(s1.getrno()==rn) { S1.disp(); F=1; Cout<<\nAre you sure??(y/n); Cin>>confirm; If(confirm==n) Fout.write((char*)&s1,sizeof(s1)); } If(f==0) Cout<<\nRecord not found!!!!\n; Fin.close(); Fout.close(); Remove(student.txt); Rename(tmp.txt,student.txt); Fin.open(student.txt); Cout<<\nNow the file contains:---\n;

While(fin.read((char*)@s1,sizeof(s1))!=NULL) { S1.disp(); } Fin.close(); Break; Case 4: Fin.open(student.txt); Fout.open(temp.txt); Cout<<\nEnter the roll number of student whose record is to be modified:--; Cin>>rn; While(fin.read((char*)&s1,sizeof(s1))!=NULL) { If(s1.getrno()==rn) { S2.getdata(); Fout.write((char*)&s2,sizeof(s2)); F=1; }else Fout.write((char*)&s1,sizeof(s1)); } If(f==0) Cout<<\nRecord not found!!!\n; Fin.close(); Fout.close(); Remove(student.txt); Rename(tmp.txt,student.txt); Fin.open(student.txt); Cout<<\nNow the file contains:---\n; Whilw(fin.read((char*)&s1,sizeo(s1))!=NULL) { S1.disp(); } Fin.close(); Break;

Case 5: Exit(0); } Cout<<\nWant to go for another operation.?(y/n):---; Cin>>c; } }

OUTPUT:------------Enter the details of student 1:-Enter your roll number:--12 Enter your name:---Neel Mukherjee Enter your total marks:---453

Enter the details of student 2:-Enter your roll number:--24 Enter your name:---Anshuman Chaterjee Enter your total marks:---390

Enter the details of student 3:-Enter your roll number:--42 Enter your name:---Srijani Banerjee Enter your total marks:---410 MENU 1.Search for a record 2.Insert a new record 3.Delete a record 4.Modify a record 5.EXIT Enter your choice:---1 Enter roll no to be searched for:---24 ROLL NO:---24 NAME:---Anshuman Chaterjee TOTAL MARKS:---390 Want to go for another operation..?(y/n):----y

MENU 1.Search for a record 2.Insert a new record 3.Delete a record 4.Modify a record 5.EXIT Enter your choice:---2 Enter the details of student whose ecord is to be inserted:--Enter your roll number:--34 Enter your name:---Neelanjana Basu Enter your total marks:---470 File now contains:--ROLL NO:---12 NAME:---Neel Mukherjee TOTAL MARKS:---453 ROLL NO:---24 NAME:---Anshuman Chaterjee TOTAL MARKS:---345 ROLL NO:---34 NAME:---Neelanjana Basu TOTAL MARKS:---470 ROLL NO:---42 NAME:---Srijani Banerjee TOTAL MARKS:---410 Want to go for another operation..?(y/n):---n

PROGRAM-13

Menu driven program to sort an integer array using selection sort and insertion sort.

#include<iostream.h> #include<process.h> void main() { int n,arr[20],i,j,t,ch; cout<<"\nEnter the range of array (maximum 20) :----"; cin>>n; cout<<"\nEnter the elements :-----\n"; for(i=0;i<n;i++) cin>>arr[i]; cout<<"\nArray before sorting :------\n"; for(i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n\tMENU"; cout<<"\n1.Sort the array using selection sort"; cout<<"2.Sort the array using insertion sort"; cout<<"\nEnter your choice (1-3) :-----"; cin>>ch; switch(ch) { case 1 : for(i=0;i<n-1;i++) { for(j=i+1;j<n;j++) { if(arr[i]>arr[j]) { t=arr[i];

arr[i]=arr[j]; arr[j]=t; } } } cout<<"\nSorted array :-----\n"; for(i=0;i<n;i++) cout<<arr[i]<<" "; case 2 : for(i=1;i<=n;i++) { t=arr[i]; j=i-1; while(t<arr[j]) { arr[j+1]=arr[j]; j--; } arr[j+1]=t; } cout<<"\nSorted array :------\n"; for(i=0;i<n;i++) cout<<arr[i]<<" "; break; } }

OUTPUT:--------Enter the range of array (maximum 20) :----------5 Enter the elements :--------1 2 3 4 5 Array before sorting :---------12345 MENU 1.Sort the array using selection sort. 2.Sort the array using insertion sort. Enter your choice (1-3) :------2 Sorted array :----------12345

PROGRAM-14

Program to implement merge sort.

#include<iostream.h> void main() { int arr1[50],arr2[50],arr3[100]; int M,N,i,j,k,T; cout<<"\nEnter the length of your first array :\n"; cin>>M; cout<<"\nEnter the length of your second array :\n"; cin>>N; cout<<"\nEnter sorted element of first array :\n "; for(i=0;i<M;i++) cin>>arr1[i]; cout<<"\nEnter sorted element of second array :\n"; for(j=0;j<N;j++) cin>>arr2[j]; i=0; //Assign to start from 0th position in array j=0; k=0; while((i<M)&&(j<N)) { if(arr1[i]<arr2[j]) { arr3[k]=arr1[i]; k=k+1; i=i+1; } else {

arr3[k]=arr2[j]; k=k+1; j=j+1; } } while(i<=M) { arr3[k]=arr1[i]; k=k+1; i=i+1; } while(j<=N) { arr3[k]=arr2[j]; k=k+1; j=j+1; } cout<<"\nThe Reversed Array is :\n"; T=M+N; for(k=0;k<T;k++) cout<<arr3[k]<<endl; }

OUTPUT:----------Enter the length of first array : 5 Enter the length of second array : 5 Enter sorted element of first array 1 2 3 4 5 Enter sorted element of second array: 6 7 8 9 11 The Reversed array is : 1 2 3 4 5 3960 6 7

8 9

PROGRAM-19

Program to display the sum of two matrices.

#include<iostream.h> #include<process.h> int main() { int a[10][10],b[10][10],c[10][10]; int i,j,m,n,p,q; cout<<"\nInput row and column of matrix-A"; cin>>m>>n; cout<<"\nInput row and column of matrix-B"; cin>>p>>q; if((m==p)&&(n==q)) { cout<<"\nMatrix can be added"; } else { cout<<"Matrix cannot be added"; exit(0); } cout<<"\nInput matrix -A"; for(i=0;i<m;i++) { for(j=0;j<n;j++) { cin>>a[i][j]; }

} cout<<"\nMATRIX-A:"; for(i=0;i<m;i++) { cout<<"\n"; for(j=0;j<n;j++) cout<<" "<<a[i][j]; } cout<<"\nInput matrix-B"; for(i=0;i<p;i++) { for(j=0;j<q;j++) cin>>b[i][j]; } cout<<"\nMATRIX-B:"; for(i=0;i<p;i++) { cout<<"\n"; for(j=0;j<q;j++) cout<<" "<<b[i][j]; } for(i=0;i<m;i++) { for(j=0;j<n;j++) c[i][j]=a[i][j]+b[i][j]; } cout<<"\nThe sum of two matrix is:"; for(i=0;i<m;i++) { cout<<"\n"; for(j=0;j<n;j++) cout<<" "<<c[i][j];

} return 0; }

OUTPUT:--------Input row and column of matrix-A3 3 Input row and column of matrix-B3 3 Matrix can be added Input matrix-A1 2 3 4 5 6 7 8 9 MATRIX-A : 1 2 3 4 5 6 7 8 9 Input matrix-B10 11 12 13

14 15 16 17 18

MATRIX-B : 10 11 12 13 14 15 16 17 18 The Sum Of Two Matrix is : 11 13 15 17 19 21 23 25 27

PROGRAM-15

Program to read an Integer Array, Sort it using Bubble sort Technique, search an elements by using Binary Search Technique.

#include<iostream.h> #include<conio.h> #include<process.h> void main() { clrscr(); int a[20],n,i,j,temp,ele; int ch; do { cout<<\n\t1.Enter Array\nt2.Sort Array\n\t3.Search\n\t4.Display\n\t5.Exit\n; cout<<\tEnter your choice:----; cin>>ch; switch(ch) { case 1: cout<<\nEnter no. of elements(<=20):; cin>>n; for(i=0;i<n;i++) cin>>a[i]; break; case 2: for(i=0;i<n;i++) { for(j=0;j<n-1;j++) { if(a[j]>a[j+1]) { temp=a[j]; a[j]=a[j+1];

a[j+1]=temp; } } } cout<<\nThe array is now sorted\n; break; case 3: cout<<\nThe elements to be searched; cin>>ele; int first=0,last=n-1,mid=0,flag=0; while(first<=last) { mid=(first+last)/2; if(a[mai]<ele { first=mid+1; } else if(a[mid]>ele) { last=mid-1; } flag=1; cout<<ele<<is present at position<<mid+1); break; } if(flag==0) cout<<\n No such elements; break; case 4: cout<<\n; for(i=0;i<n;i++) cout<<a[j]<< ; break; case 5: exit(0);

} } while(ch!=5); } OUTPUT :-------------1. 2. 3. 4. 5. Enter Array Sort Array Search Display Exit

Enter your choice:---- 1 Enter no. of elements (<=20): 5 6 5 8 3 4 1. 2. 3. 4. 5. Enter Array Sort Array Search Display Exit

Enter your choice:---- 2 The array is now sorted 1. 2. 3. 4. 5. Enter Array Sort Array Search Display Exit

Enter your choice:---- 3 The elements to be searched 6 6 is present at 4 1. 2. 3. 4. 5. Enter Array Sort Array Search Display Exit

Enter your choice:---- 4 3 4 5 6 8 1. 2. 3. 4. 5. Enter Array Sort Array Search Display Exit

Enter your choice:---- 5

PROGRAM-16

Program to Insert an Elements at a specific position in a 1-D Array.

#include<iostream.h> #include<conio.h> void main() { clrscr(); int n,i,arr[20],ele,pos; cout<<\nEnter the range of array:----\n; cin>>n; cout<<\nEnter the elements of array:----\n; for(i=0;i<=n;i++) cin>>arr[i]; cout<<\nARRAY:----\n; for(i=0;i<n;i++) cout<<arr[i]<< ; cout<<\nEnter the lements you want to insert and at what position:----; cin>>ele>>pos; for(i=n;i>=pos;i--) arr[pos-1]=ele; arr[pos-1]=ele; n=n+1; cout<<\nArray afterinsertion:----\n; for(i=0;i<n;i++) cout<<arr[i]<< ; getch(); }

OUTPUT:-----------Enter the range of array:---10 Enter the elements of array:---10 9 8 7 6 4 3 2 1 ARRAY:---10 9 8 7 6 5 4 3 2 1 Enter the elements you want to insert and at what position:---- 32 1 Array after insertion:---32 10 9 8 7 6 5 4 3 2 1

PROGRAM-17

Program to Delete an Element from a specific position in a 1-D Array.

#include<iostream.h> #include<conio.h> #include<process.h> void main() { clrscr(); int n,i,arr[20],ele,pos,j,c=0; cout<<\nEnter the range of array:----\n; cin>>n; cout<<\nEnter the elements of array:----\n; for(i=0;i<=n;i++) cin>>arr[i]; cout<<\nARRAY:----\n; for(i=0;i<n;i++) cout<<arr[i]<< ; cout<<\nEnter the element you want to delete:----; cin>>ele; for(i=0;i<=n;i++) { pos=i; arr[i]=0; for(j=i;j<(n-1);j++) arr[j]=arr[j+1]; n=n-1; cout<<ele<<was present at<<(pos+1)<<and is now deleted!!\n; c=1; break; } if(c==0) { cout<<\nNo such elements is there, which you want to deleted!!\n;

getch(); exit(0); } cout<<\nArray after deletion:----\n; for(i=0;i<n;i++) cout<<arr[i]<< ; getch() }

OUTPUT:---------Enter the range of array:---10 Enter the elements of array:---100 90 80 70 60 50 40 30 ARRAY:---100 90 80 70 60 50 40 30 Enter the elements you want to delete :---- 40 65 was present at 7 and is now deleted!! After deletion:---100 90 80 70 60 50 30

PROGRAM-18

Program to accept a 2-D Array of Integers and display the elements which are exactly two Digit numbers.

#include<iostream.h> #include<conio.h> void twodigit(int a[10][10], int m, int n) { int i,j,flag=0; cout<<The two digit Number are: ; for(i=0;i<m;i++) { for(j=0;j<n;j++) { if(a[i][j]>=10&&a[i][j]<=99) { cout<<a[i][j]<<ends; flag=1; } } } if(flag==0) cout<<None; } void main() { clrscr(); int a[10][10],i,j,m,n; cout<<\n Enter no. of rows: ; cin>>m; cout<<\nEnter the no. of columns: ; cin>>n; cout<<\nEnter the elements of the array: ; for(i=0;i<n;i++) { for(j=0;j<n;j++) cin>>a[i][j]; } twodigit(a,m,n); getch(); }

OUTPUT:--------------Enter no. of rows: 3 Enter the no. of columns: 3 Enter the elements of the array: 12 7 45 65 35 69 179 64 35 The two digit no are: 12 45 65 35 69 64 35

PROGRAM-20

Program to Display the capital of a given Country and to display the Tabular Report of the Country and corresponding Capital.

#include<iostream.h> #include<stdio.h> #include<conio.h> #include<string.h> struct world { char country[30]; char capital[30]; }; void main() { clrscr(); world w[10]; int i=0,n; cout<<Enter no. of records(<=10): ; cin>>n; for(i=0;i<n;i++) { cout<<\mEnter the country: ; get(wi[i].country); cout<<Enter the capital: ; gets(w[i].capital); } char ch,*cont; int flag; cout<<\n\t1.Search for capital\n\t2.List all Reacord\n\t3.Exit\n; cin>>ch; do { if(ch==1) { cout<<\nEnter the country: ; gets(cont); flag=0; for(i-0;i<n;i++) {

if(strcmp(cont,w[i].country)==0) { cout<<\n capital is: <<w[i].capital; flag=1; break; } } if(flag==0) cout<<\ncountry not found; } if(ch==2) { cout<<\nCOUNTRY\t\tCAPITAL; cout<<>\n--------\t\t--------; for(i=0;i<n;i++) cout<<\n<<(w[i].country)<<\t\t<<(w[i].capital); } cout<<\n\t1.Search for capital\n\t2.List all Records\n\t3.Exit; cin>>ch; } while(ch!=3); getch(); }

OUTPUT:---------Enter no. of records(<=10): 5 Enter the country: INDIA Enter the capital:NEW DELHI Enter the country: BRAZIL Enter the capital: BRAZILIA Enter the country: SRILANKA Enter the capital: COLOMBO Enter the country: JAPAN Enter the capital: TOKYO Enter the country: CHINA Enter the capital: BEIJING 1. Search for capital 2. List all records 3. Exit Enter the country: CHINA Enter the capital: BEIJING 1. Search for capital 2. List all records 3. Exit COUNTRY -------------INDIA BRAZIL SRILANKA JAPAN CHINA CAPITAL ----------DELHI BRAZILIA COLOMBO TOKYO BEIJING

1. Search for capital

2. List all records 3. Exit

PROGRAM-21

Program to create a Library Management System (Implementing Class).

#include<iostream.h> #include<stdio.h> #include<conio.h> #include<process.h> class Library { int Acc_No; char Author[20]; char Title[20]; char Publisher[20]; float Price; int no_copies; public: void add() { cout<<Enter the Accession Number:----; cin<<Acc_No; cout<<Enter the Author:----; gets(Author); cout<<Enter the title:----; gets(Title); cout<<Enter the publisher:----; gets(publisher); cout<<Enter the Price of the Book:----; cin>>Price; cout<<Enter Number of copies:----; cin<<no_copies; } int search(int ano) { if(ano==Acc_No) return 1; else return 0; }

voidDisplay() { cout<<The Author Name is:<<Author<<endl; cout<<The Price of the Book: <<Price<<endl; } }; void main() { clrcsr(); library Lib[10]; int ch,x,i,c,f; char ans=Y; i-0 while(ans==Y||ans==Y) { c=0; cout<<\n1.To add; cout<<\n2.For search; cout<<\n3.For Display; cout<<\n4.Exit; cout<<\nEnter Your choice; cin>>ch; switch(ch) { case 1: Lib[i].add(); i++; braek; case 2: int f; cout<<Enter the accession number to be searchaed; cin>>x; for(int j=0;j<i;j++) {

f=Lib[j].search(x); if(f==1) { cout<<Book Exists; c=1; break; } } if(c==0) cout<<Book does not exists; break; case 3: Lib[j].Display(); break; case 4: exit(0); } cout<<Do u want to continue; cin>>ans;} getch() } }

OUTPUT:---------1.To add 2.For Search 3.For Display 4.Exit Enter you choice 1 Enter the Accession Number:---- 123 Enter the Author:---- Sumita Arora Enter the Title:---- Computer Science Enter the Publisher:---- Dhanpat Rai Enter the Price of the Book:---- 200 Enter Number of copies:---- 10 Do you want to continue Y 1.To add 2.For Search 3.For Display 4.Exit Enter your choice 2 Enter the accession number to be searched 123 Book Exists do you want to continue Y 1.To add 2.For Search 3.For Display 4.Exit Enter you choice 3 The Author Name is: Sumita Arora The Price of the Book:---- 200 Do you want to continue N

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy