Professional Documents
Culture Documents
Practical File
Practical File
Practical
File
INDEX
S.No.
1.)
2.)
3.)
4.)
5.)
6.)
7.)
8.)
9.)
10.)
11.)
12.)
13.)
14.)
15.)
16.)
17.)
18.)
19.)
20.)
21.)
22.)
23.)
24.)
25.)
Practical
SQL (1)
SQL (2)
SQL (3)
SQL (4)
SQL (5)
Ascending Order
Menu
Class Publication
Merging of Arrays
Sum of Row and Column
Series 1
Series 2
Series 3
Series 4
Size of File
Searching of a Record in a File
Deletion of a Record in File
Selection Sort
Structure
Insertion in a Linked List
Deletion in a Linked List
Stack as Linked List
Static Stack
Queue as Linked List
Circular Queue
Sign
Thunder
Bolts
My First
C++
C++
Brainwor
k
Fast Cook
Author_Na
me
William
Hopkins
Anna
Roberts
Brian &
Brooke
A.W.
Rossaine
LataKapoor
Publishe Pric
rs
e
First Publ. 750
First Publ.
700
EPB
250
Typ
e
FicTion
FicTion
Text
Qty
TDH
325
Text
EPB
350
Cook
-ery
10
5
10
Table ISSUED
Book_Id
F001
T001
Quantity Issued
3
1
C001
Ans.
Bookname
My First C++
C++ Brainworks
Fast Cook
Ans.
Author_name
Brian & Brooke
A.W. Rossaine
LataKapoor
PRIC
E
32000
DISCOU
NT
15
9000
10
8500
10
20000
20
15000
20
7000
19
16000
20
30000
9000
25
15
11000
15
Table NEWONES
S.N
o.
11
ITEMNA
ME
TYPE
12
White
Double
Wood
Bed
James 007
Sofa
13
Tom Look
Baby
Cot
DATE
OF
STOCK
23/02/0
2
20/02/0
3
21/02/0
3
PRIC
E
DISCOU
NT
2000
0
1500
0
7000
20
15
10
Write
SQL
Ans.
Ans.
Ans.
Ans.
Clas
s
10
11
12
13
14
8
7
7
9
15
10
Name
Game 1
Samm
Cricket
er
Sujit
Tennis
Kamal Swimming
Venna
Tennis
Arehan Basketball
a
Arpit
Cricket
Grade Game 2
B
Grade
2
A
B
C
A
Swimming
Skating
Football
Tennis
Cricket
A
C
B
A
A
Athletics
Name
Deptid
1
2
3
4
5
6
Deepali Gupta
RajatTyagi
Hari Mohan
Harry
Sumit Mittal
Jyoti
101
101
102
102
103
101
Qualificati
on
M.C.A.
B.C.A.
B.A.
M.A.
B.Tech.
M.Tech.
Sex
F
M
M
M
M
F
Table SALARY
Eid
1
2
3
4
5
6
Basic
6000
2000
1000
1500
8000
10000
D.A.
2000
300
300
390
900
300
H.R.A.
2300
300
300
490
900
490
Bonus
200
30
40
30
80
89
Name
Jyoti (*)
COUNT
Ans.
Sex
2
F
4
M
MAX (Basic)
10000
Ans.
Ans.
Charg
es
300
Se
x
M
200
200
300
250
300
800
300
800
400
F
M
M
M
F
F
F
M
F
AVG (Charges)
400
Ans.
{for(k=0;k<3;k++)
c[i][j]=x[i][k]*y[k][j];
}
}
cout<<"The Product of Matrices is \n";
for(i=0;i<3;i++)
{for(j=0;j<3;j++)
{cout<<c[i][j]<<" ";
}
cout<<endl;
}
}
void menu()
{clrscr();
cout<<"MENU\n";
cout<<"Enter the choice\n";
cout<<"1.Add Matrices\n2.Subtract Matrices\n3.Multiply
Matrices\n4.Exit\n";
int n;
cin>>n;
switch(n)
{case 1:add();
break;
case 2:subtract();
break;
case 3:multiply();
break;
case 4:exit(0);
default:cout<<"Wrong Choice";
break;
}
}
void main()
{clrscr();
cout<<"Enter Matrices\n";
cout<<"Enter the 1st Matrice\n";
for(i=0;i<3;i++)
{for(j=0;j<3;j++)
cin>>x[i][j];
}
cout<<"Enter the 2nd Matrice\n";
for(i=0;i<3;i++)
{for(j=0;j<3;j++)
cin>>y[i][j];
}
cout<<"\n";
menu();
getch();
}
PUBLIC MEMBERS
Ans.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class publication
{char title[25][10];
float price[10];
public:
int n;
void getdata();
void putdata();
}a;
void publication::putdata()
{cout<<"\nData-->";
for(int j=0;j<n;j++)
{cout<<"\nBook-"<<j+1;
cout<<"\nTitle-"<<title[j];
cout<<"\nPrice-"<<price[j];
}
}
void publication::getdata()
{cout<<"Enter the Data";
for(int i=0;i<n;i++)
{cout<<"\nBook-"<<i+1;
cout<<"\nTitle-";
gets(title[i]);
cout<<"\nPrice-";
cin>>price[i];
}
}
void main()
{clrscr();
cout<<"\nNo. of Books ";
cin>>a.n;
a.getdata();
a.putdata();
getch();}
#include<iostream.h>
#include<conio.h>
void merge(int a[50],int m,int b[50],int n,int c[50])
{int x,y,z;
for(x=0,y=n-1,z=0;x<m&&y>=0;)
{if(a[x]<=b[y])
c[z++]=a[x++];
else
c[z++]=b[y--];
}
if(n>m)
{while(n>m)
c[z++]=a[x++];
}
else
{while(b>=0)
c[z++]=b[y--];
}
}
void main()
{int a[50],b[50],c[50],mn=0,m,n,i;
cout<<"Enter the size of 1st array - \n";
cin>>m;
cout<<"Enter 1st array element in ascending order - \n";
for(i=0;i<n;i++)
cin>>a[i];
cout<<"Enter 2nd array - \n";
cin>>n;
mn=m+n;
cout<<"Enter 2nd array element in descending order - \n";
for(i=0;i<n;i++)
cin>>b[i];
merge(a,m,b,n,c);
cout<<"In the merged array B shown : \n";
for(i=0;i<mn;i++)
cout<<c[i];
cout<<"\n";
}
Ans.
#include<iostream.h>
#include<conio.h>
void main()
{clrscr();
int i,j,a[3][3],r=0,c=0;
cout<<"Enter the Matrice";
for(i=0;i<3;i++)
{for(j=0;j<3;j++)
cin>>a[i][j];
}
for(j=0;j<3;j++)
{i=0;r=0;
r+=a[i][j];
cout<<"The sum of row "<<"is "<<r<<"\n";
i++;
}
for(i=0;i<3;i++)
{j=0;c=0;
c+=a[i][j];
cout<<"The sum of column "<<"is "<<c<<"\n";
j++;
}
getch();
}
Ans.
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr ();
inta,b=0,i;
cout<<"Enter the value of n \n";
cin>>a;
for (i=1;i<=a;i++)
b+=pow(i,2);
cout<<b;
getch();
}
#include<iostream.h>
#include<conio.h>
void main()
{ clrscr ();
floata,b,c,d=1,e=0;
cout<<"To print the series: x+x/2!+x/3!......+x/n!\n"<<"Enter
the values of x and n \n" ;
cin>>a>>b;
for (c=1;c<=b;c++)
{d*=c;
e+=a/d;
}
cout<<e;
getch();
}
Ans.
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main ()
{
clrscr ();
cout<<"Enter the value of x \n";
floatx,z,v=-1,d=0;
cin>>x;
cin>>n;
int a=0;
for (z=1;z<=n;z++)
{
a=y*pow(x,z);
v*=z;
d+=a/v;}
cout<<d;
getch ();
}
Ans.
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main ()
{clrscr ();
Float x,n,c,d=1,e,f=1,g;
cout<<"Enter the value of x and n\n";
cin>>x>>n;
g=x;
for (c=1;c<=n;c=c+2)
{ d*=-1;
e=d*pow(x,c);
f*=c*(c-1);
g+=f/e;}
cout<<g;
getch ();
}
Ans.
#include<iostream.h>
#include<conio.h>
void main()
{clrscr();
int i,j,min,minat,temp,a[10];
for(i=0;i<10;i++)
cin>>a[i];
for(i=0;i<(10-1);i++)
{minat=i;
min=a[i];
for(j=i+1;j<10;j++)
{if(min>a[j])
{minat=j;
min=a[j];
}
}
temp=a[i];
a[i]=a[minat];
a[minat]=temp;
}
for(i=0;i<10;i++)
cout<<a[i];
getch(); }
Ans.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
struct student
{int marks,roll_no;
char name[40];
}s[100];
void main()
{clrscr();
student s1;
cout<<"Enter no. of students\n";
int n;
cin>>n;
cout<<"Enter Details";
for(int i=0;i<n;i++)
{cout<<"\nStudent-->"<<i+1;
cout<<"\nName-->";
gets(s[i].name);
cout<<"\nRoll No.-->";
cin>>s[i].roll_no;
cout<<"\nMarks";
cin>>s[i].marks;
}
for(int j=0;j<n;j++)
{for(i=0;i<n;i++)
if(s[i].marks<s[i+1].marks)
{s1=s[i];
s[i]=s[i+1];
s[i+1]=s1;
}
}
cout<<"Result in Decreasing order";
for(i=0;i<n;i++)
{cout<<"\nName-->"<<s[i].name;
cout<<"\nRoll No.-->"<<s[i].roll_no;
cout<<"\nMarks-->"<<s[i].marks;
}
getch();
}
#include<iostream.h>
#include<conio.h>
#include<process.h>
#include<stdio.h>
struct node
{char name[20];
int age;
node *link;
}*ptr=NULL,*save=NULL;
class stack
{node *top;
public:
stack()
{top=NULL;
}
void stackpush();
void stackpop();
void display();
}st;
void stack::stackpush()
{ptr=new node;
if(ptr==NULL)
{cout<<"ERROR.... ";
}
else
{
cout<<"Enter the name ";
gets(ptr->name);
cout<<"Enter the age ";
cin>>ptr->age;
ptr->link=NULL;
if(top==NULL)
{top=ptr;
}
else
{ptr->link=top;
top=ptr;
}
}
}
void stack::stackpop()
{if(top==NULL)
{cout<<"Underflow ";
}
else
{save=top;
top=top->link;
cout<<"Name ";
puts(save->name);
cout<<"Age "<<save->age;
delete save;
}
}
void stack::display()
{if(top==NULL)
{cout<<"No elements.."<<endl;
}
else
{ptr=top;
while(ptr!=NULL)
{cout<<"\nName ";
puts(ptr->name);
cout<<"Age "<<ptr->age;
ptr=ptr->link;
}
}
}
void main()
{clrscr();
int ch;
X:
cout<<"\nEnter your
choice\n1.Insert\n2.Delete\n3.Display\n4.Exit\n";
cin>>ch;
switch(ch)
{case 1:st.stackpush();
goto X;
case 2:st.stackpop();
goto X;
case 3:st.display();
goto X;
default:cout<<"Wrong choice ";
goto X;
case 4:exit(0);
}
getch(); }
#include<iostream.h>
#include<conio.h>
#include<process.h>
void main()
{
clrscr();
int ch,i,top=-1,stack[5];
x:
cout<<endl<<endl;
cout<<"Enter Choice 1> Insert 2> Delete 3>exit "<<endl;
cin>>ch;
switch(ch)
{
case 1:
top++;
if(top<=4)
{
cout<<"Enter The Element"<<endl;
cin>>stack[top];
cout<<"The Stack is"<<endl;
for(i=0;i<=top;i++)
cout<<stack[i]<<"--> ";
goto x;
}
else
{
cout<<" ************* Stack OVERFLOW ********** "<<endl;
goto x;}
case 2:
if(top>=0)
{
top--;
cout<<"Stack is"<<endl;
for(i=0;i<=top;i++)
cout<<stack[i]<<" -> ";
goto x;
}
else
{
cout<<"************** Stack UNDER FLOW ***********"<<endl;
goto x;
}
case 3:
exit(0);
default :
#include<process.h>
void main()
{
clrscr();
int ch,i,rear=-1,front=-1,queue[10];
x:
cout<<endl<<endl;
cout<<"Enter Choice 1> Insert 2> Delete 3>exit "<<endl;
cin>>ch;
switch(ch)
{
case 1:
if(front==-1)
{front=0;}
rear++;
if(rear<=9)
{cout<<"Enter The Element"<<endl;
cin>>queue[rear];
cout<<"Queue is"<<endl;
for(i=0;i<=rear;i++)
{cout<<queue[i];}
}
else
{cout<<"****************QUEUE OVERFLOW****************";
}
goto x;
case 2:
if(rear==-1)
{rear=0;}
if(front==-1)
{cout<<"*************** UNDER FLOW **********"<<endl;goto
x;}
else
if(rear==front)
{queue[front]='\o';
front=-1;
rear=-1;
goto x;
}
else
{queue[front]='\o';
front++;
}
cout<<"Queue is"<<endl;
for(i=0;i<=rear;i++)
{cout<<queue[i];}
goto x;
case 3:
exit(0);
default :
goto x; }}
#include<process.h>
class queue
{int data[10];
int front,rear;
public:
queue()
{front=-1;
rear=-1;
}
void add();
void remove();
void display();
};
void queue::add()
{if((rear+1==front)||(rear==9&&front==0))
{cout<<"Overflow ";
}
else
{if((rear==-1) &&(front==-1))
{rear=0;
front=0;
}
else if(rear==9)
{rear=0;
}
else
{rear++;
}
cout<<"Enter the element ";
cin>>data[rear];
}
}
void queue::remove()
{if(front==-1&&rear==-1)
{cout<<"Underflow ";
}
else
{if(front==9)
{front=0;
}
else if(front==rear)
{front=-1;
rear=-1;
}
else
{front++;
}
}
}
void queue::display()
{int i=0,n=9;
if(rear==-1)
{cout<<"No elements.."<<endl;
}
else
{ if(rear>front)
{for(i=0;i<front;i++)
{cout<<"_";
}
for(i=front;i<=rear;i++)
{cout<<data[i];
}
for(i=rear+1;i<n;i++)
{cout<<"_";
}
}
else
{for(i=0;i<=rear;i++)
{cout<<data[i];
}
for(i=rear+1;i<front;i++)
{cout<<"_";
}
for(i=front;i<n;i++)
{cout<<data[i];
}
}}
}
void main()
{clrscr();
int ch;
queue queue;
X:
cout<<"\nEnter your
choice\n1.Insert\n2.Delete\n3.Display\n4.Exit\n";
cin>>ch;
switch(ch)
{case 1:queue.add();
goto X;
case 2:queue.remove();
goto X;
case 3:queue.display();
goto X;
case 4:exit(0);
}
getch();
}