Documente Academic
Documente Profesional
Documente Cultură
KRMWS
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
Bookna
me
The
Tears
Thunder
Bolts
My First
C++
C++
Brainwor
k
Fast
Cook
Typ
e
FicTion
FicTion
Text
Qty
Text
LataKapoor
Coo
kery
EPB
350
Table ISSUED
Book_Id
F001
T001
Quantity Issued
3
1
C001
10
5
10
Ans.
Bookname
Author_name
My First C++
Brian & Brooke
C++ Brainworks
A.W. Rossaine
Fast Cook
LataKapoor
SELECT Book_Name, Author_Name FROM Books
where Price<500;
3)
Ans.
Ans.
ITEMNA
ME
Red Rose
2
3
4
5
6
7
8
9
TYPE
Doubl
e Bed
Soft Touch Baby
Cot
Jerrys
Baby
House
Cot
Rough
Office
Wood
Table
Comfort
Doubl
Zone
e Bed
Jerry Look Baby
Cot
Lion King Office
Table
Royal
Sofa
Tiger
Park
Sofa
Sitting
DATE
OF
STOCK
23/02/02
PRIC
E
DISCOU
NT
32000
15
20/11/02
9000
10
19/02/02
8500
10
01/01/02
20000
20
12/01/02
15000
20
24/02/02
7000
19
20/02/02
16000
20
22/02/02
30000
25
13/12/01
9000
15
10
Dine
Paradise
Dinin
g
Table
19/02/02
11000
15
Table NEWONES
S.
No.
11
ITEMNA
ME
TYPE
12
White
Double
Wood
Bed
James 007
Sofa
13
Tom Look
Baby
Cot
Write
SQL
Ans.
Ans.
Ans.
Ans.
Clas
s
Name
Game 1
10
Cricket
11
12
8
7
Samm
er
Sujit
Kamal
13
14
7
9
Tennis
Swimmin
g
Tennis
Basketball
15
10
Cricket
Venna
Areha
na
Arpit
Grade Game 2
Grade
2
A
B
Swimming
Skating
Football
A
C
B
C
A
Tennis
Cricket
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
COUNT (*)
2
4
Name
Jyoti
Sex
F
M
MAX (Basic)
10000
Ans.
3) SELECT COUNT (*) from Employee GROUP BY Sex;
Ans.
Ans.
Name
Ag
e
Sandee 65
p
Ravina 24
Karan 45
Tarun 12
Zubin 36
Ketaki 16
Leena 29
Zareen 45
Departme
nt
Surgery
Date of
Adm
23/02/98
Charg
es
300
Se
x
M
Orthopedic
Orthopedic
Surgery
E.N.T.
E.N.T.
Cardiology
Gynecology
20/01/98
19/02/98
01/01/98
12/01/98
24/02/98
20/02/98
22/02/98
200
200
300
250
300
800
300
F
M
M
M
F
F
F
9
Kush
10 Shailya
19
31
Gynecology 13/01/98
Nuclear
19/02/98
Medicine
800
400
M
F
Ans.
Ans.
Ans.
Ans.
{int b[3][3];
for(i=0;i<3;i++)
{for(j=0;j<3;j++)
b[i][j]=x[i][j]-y[i][j];
}
cout<<"The Subtracted Matrices is \n";
for(i=0;i<3;i++)
{for(j=0;j<3;j++)
{cout<<b[i][j]<<" ";
}
cout<<endl;
}
}
void multiply()
{int c[3][3];
for(i=0;i<3;i++)
{for(j=0;j<3;j++)
{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
Function getdata() to accept Data
Function putdata() to display Data
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();}
{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();
}
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;
char filename[20];
cout<<"Enter filename: \n";
gets(filename);
ifstream fin("size.txt",ios::in|ios::ate);
while(fin.eof())
{long bytes=fin.tellg();
cout<<"File Size is: "<<bytes<<"Bytes";
}
getch();
}
#include<string.h>
class student
{int age;
char name[20];
public:
void getname()
{cout<<"Enter Name \n";
gets(name);
}
void getage()
{ cout<<"Enter Age \n";
cin>>age;
}
void putdata()
{cout<<"Name: "<<name<<"\nAge: "<<age;
}
char sname()(return name;}
}s;
void main()
{clrscr();
ifstream fin("student.txt");
char code[50];
gets(code);
s.getname();
s.getage();
while(fin.eof())
{fin.read((char*)&s,sizeof(s));
if(strcmp(s.sname(),code))
{s.putdata();
break;
}
if(strcmp(s.sname()!,code))
cout<<"The entered Age is invalid";
}
fin.close();
}
#include<conio.h>
#include<stdio.h>
class student
{int age;
char name[20];
public:
void getdata()
{cout<<"Enter Name \n";
gets(name);
cout<<"Enter Age \n";
cin>>age;
}
void putdata()
{cout<<"Name: "<<name<<"\nAge: "<<age;
}
}s;
void main()
{clrscr();
ifstream fin("student.txt");
ofstream fout("temp.txt");
int code;
cin>>code;
s.getdata();
while(fin.eof())
{fin.read((char*)&s,sizeof(s));
}
fin.close();
fout.close();
remove("student.txt");
rename("temp.txt","student.txt");
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();
}
Ans.
#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(); }
{
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 :
cout<<"WRONG CHOICE !!!!!!!!!!! "<<endl;
goto x;
}
}
Ans.
#include<iostream.h>
#include<conio.h>
#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; }}
}
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();
}