Practical File All Program

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

Page |1

1.To Print The Given Numbers In Ascending Order Using Bubble Sort:
#include<iostream.h>
#include<conio.h>
void bubblesort(int[],int);
void main()
{
clrscr();
int a[50],n,i;
cout<<"enter size of array:";
cin>>n;
cout<<"enter array elements \n";
for(i=0;i<n;i++)
{ cin>>a[i];}
bubblesort(a,n);
cout<<"the sorted array is shown\n";
for(i=0;i<n;i++)
{ cout<<a[i]<<" ";}
cout<<endl;
getch();
}
void bubblesort(int a[],int n)
{
int tmp,cnt=0;
for(int i=0;i<n;i++)
{
for(int j=0;j<(n-1);j++)
{
if(a[j]>a[j+1])
{
tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
}
cout<<"the array after loop-"<<++cnt<<"is:";
for(int k=0;k<n;k++)
cout<<a[k]<<" ";
cout<<endl;
}
}
Page |2

OUTPUT OF THE FOLLOWING PROGRAM:


Page |3

2.To Print The Given Numbers In Descending Order Using Bubble Sort:
#include<iostream.h>
#include<conio.h>
void bubblesort(int[],int);
void main()
{
clrscr();
int a[50],n,i;
cout<<"enter size of array:";
cin>>n;
cout<<"enter array elements \n";
for(i=0;i<n;i++)
{ cin>>a[i];}
bubblesort(a,n);
cout<<"the sorted array is shown\n";
for(i=0;i<n;i++)
{ cout<<a[i]<<" ";}
cout<<endl;
getch();
}
void bubblesort(int a[],int n)
{
int tmp,cnt=0;
for(int i=0;i<n;i++)
{
for(int j=0;j<(n-1);j++)
{
if(a[j]<a[j+1])
{
tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
}
cout<<"the array after loop-"<<++cnt<<"is:";
for(int k=0;k<n;k++)
cout<<a[k]<<" ";
cout<<endl;
}
}
Page |4

OUTPUT OF THE FOLLOWING PROGRAM:


Page |5

3.To Print The Given Numbers In Ascending Order Using Insertion Sort
#include<iostream.h>
#include<conio.h>
#include<process.h>
int findpos(int[],int,int);
void main()
{
clrscr();
int a[50],n,item,index,i;
char ch='y';
cout<<"enter the size of array:";
cin>>n;
cout<<"\n enter array elements";
for(i=0;i<n;i++)
{ cin>>a[i];}
while(ch=='y'||ch=='Y')
{
cout<<"\n enter the elements to be inserted....";
cin>>item;
if(n==50)
{
cout<<"overflown!";
exit(1);
}
index=findpos(a,n,item);
for(i=n;i>index;i--)
{ a[i]=a[i-1];}
a[index]=item;
n+=1;
cout<<"want to insert more elements ?(y\n)";
cin>>ch;
}
cout<<"the array now is as shown below....\n";
for(i=0;i<n;i++)
cout<<a[i]<<" ";
cout<<endl;
getch();
}
int findpos(int a[],int size,int item)
{
int pos;
Page |6

if(item<a[0])
pos=0;
else
{
for(int i=0;i<size-1;i++)
{
if(a[i]<=item&&item<a[i+1])
{
pos=i+1;
break;
}
if(i==size-1)
pos=size;
}
}
return pos;
}
OUTPUT OF THE FOLLOWING PROGRAM:
Page |7

4.To Print Given Numbers In Ascending Order Using Selection Sort


#include<iostream.h>
#include<conio.h>
void selectsort(int[],int);
void main()
{
clrscr();
int a[50],n,i;
cout<<"enter the size:";
cin>>n;
cout<<"enter the array elements\n";
for(i=0;i<n;i++)
{ cin>>a[i]; }
selectsort(a,n);
cout<<"the sorted array is\n";
for(i=0;i<n;i++)
{ cout<<a[i]<<" "; }
getch();
}
void selectsort(int a[],int size)
{ int small,temp,pos,i,j;
for(i=0;i<size;i++)
{
small=a[i];
pos=i;
for(j=i+1;j<size;j++)
{
if(a[j]<small)
{
small=a[j];
pos=j;
}
}
temp=a[i];
a[i]=a[pos];
a[pos]=temp;
}
}
Page |8

OUTPUT OF THE FOLLOWING PROGRAM:


Page |9

5.To Merge The Two Arrays Element And Print The Same In Ascending
Order Using Merge Sort:
#include<iostream.h>
#include<conio.h>
void mergeit(int A[],int m,int B[],int n,int C[]);
void main()
{
clrscr();
int A[50],B[50],C[50],m,n,mn=0,i;
cout<<"enter size of first array:";
cin>>m;
cout<<"enter the elements ascending order:\n";
for(i=0;i<m;i++)
{ cin>>A[i]; }
cout<<"enter the size of 2nd array:";
cin>>n;
mn=m+n;
cout<<"enter the elements of 2nd array in descending order\n";
for(i=0;i<n;i++)
{ cin>>B[i]; }
mergeit(A,m,B,n,C);
for(i=0;i<mn;i++)
cout<<C[i]<<" ";
cout<<"\n";
getch();
}
void mergeit(int A[],int m,int B[],int n,int C[])
{
int a,b,c;
for(a=0,b=n-1,c=0;a<m&&b>=0;)
{ if(A[a]<=B[b])
C[c++]=A[a++];
else
C[c++]=B[b--];
}
if(a<m)
{
while(a<m)
C[c++]=A[a++]; }
else
{
P a g e | 10

while(b>=0)
C[c++]=B[b++]; }
}
OUTPUT OF THE FOLLOWING PROGRAM:
P a g e | 11

6.To Merge The Two Arrays Element And Print The Same In Descending
Order Using Merge Sort:
#include<iostream.h>
#include<conio.h>
void mergeit(int A[],int m,int B[],int n,int C[]);
void main()
{
clrscr();
int A[50],B[50],C[50],m,n,mn=0,i;
cout<<"enter the size of 1st array:";
cin>>m;
cout<<"enter the elements in ascending order:\n";
for(i=0;i<m;i++)
{ cin>>A[i];}
cout<<"enter the size of the 2nd array:";
cin>>n;
mn=m+n;
cout<<"enter the elements in descending order:\n";
for(i=0;i<n;i++)
{ cin>>B[i]; }
mergeit(A,m,B,n,C);
for(i=mn-1;i>=0;i--)
cout<<C[i]<<" ";
cout<<"\n";
getch();
}
void mergeit(int A[],int m,int B[],int n,int C[])
{ int a,b,c;
for(a=0,b=n-1,c=0;a<m&&b>=0;)
{ if(A[a]<=B[b])
C[c++]=A[a++];
else
C[c++]=B[b--];
}
if(a<m)
{ while(a<m)
C[c++]=A[a++];
}
else
{
while(b>=0)
P a g e | 12

C[c++]=B[b++];
}
}
OUTPUT OF THE FOLLOWING PROGRAM:
P a g e | 13

7.To Implement Linear Search In 1-D Array:


#include<iostream.h>
#include<conio.h>
int lsearch(int a[],int n,int s);
void main()
{ clrscr();
int a[50],n,s,i,pos=0;
cout<<"enter the size of array:";
cin>>n;
cout<<"enter the elements:";
for(i=0;i<n;i++)
{ cin>>a[i]; }
cout<<"enter the numbers to be searched:";
cin>>s;pos=lsearch(a,n,s);
if(pos==-1)
{ cout<<"not found"; }
else
{ cout<<"elements at pos:"<<(pos+1)<<"\n";}
getch();
}
int lsearch(int a[],int n,int s)
{ for(int i=0;i<n;i++)
{
if(a[i]==s)
return i;
}
return -1;
}
OUTPUT OF THE FOLLOWING PROGRAM:
P a g e | 14

8.To Implement Binary Search In 1-D Array:


#include<iostream.h>
#include<conio.h>
int bsearch(int[],int,int);
void main()
{
clrscr();
int a[50],n,item,index,i;
cout<<"enter the size :";
cin>>n;
cout<<"enter the elements:\n";
for(i=0;i<n;i++)
{ cin>>a[i]; }
cout<<"enter the num to be searched:";
cin>>item;
index=bsearch(a,n,item);
if(index==-1)
{
cout<<"the num not found!";
}
else
{ cout<<"the num found at :"<<index<<",postion:"<<(index+1)<<"\n"; }
getch();
}
int bsearch(int a[],int size,int item)
{
int beg=0,mid=0,last=size-1;
while(beg<=last)
{
mid=(beg+last)/2;
if(a[mid]==item)
{ return mid; }
else if(a[mid]<item)
{ beg=mid+1; }
else
{ last=mid-1; }
}
return -1;
}
P a g e | 15

OUTPUT OF THE FOLLOWING PROGRAM:


P a g e | 16

9.To Implement Sum Of Matrices In 2-D Array:


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a[10][10],b[10][10],sum[10][10],i,j,r,c;
cout<<"enter the rows:";
cin>>r;
cout<<"enter the columns:";
cin>>c;
cout<<"enter the elements:";
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{ cin>>a[i][j];}}
cout<<"elements of the first matrix are \n";
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{ cout<<a[i][j]<<" "; }
cout<<endl;
}
cout<<"enter the elements of the 2nd :";
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{ cin>>b[i][j]; }
}
cout<<"the elements of the 2nd matrix are\n";
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{ cout<<b[i][j]<<" "; }
cout<<endl;
}
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{ sum[i][j]=a[i][j]+b[i][j]; }
}
P a g e | 17

cout<<"sum of matrix is:\n";


for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{ cout<<sum[i][j]<<" "; }
cout<<endl;
}
getch();
}
OUTPUT OF THE FOLLOWING PROGRAM:
P a g e | 18

10.To Implement The Transpose Of A Matrix:


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a[10][10],i,j,r,c;
cout<<"enter the no of rows of the matrix:";
cin>>r;
cout<<"enter the no of column of the matrix:";
cin>>c;
cout<<"enter the elements of the matrix:\n";
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{ cin>>a[i][j]; }
cout<<"\n";
}
cout<<"elements are:\n";
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{ cout<<a[i][j]<<" "; }
cout<<"\n";
}
cout<<"transpose is:\n";
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{ cout<<a[j][i]<<" "; }
cout<<"\n";
}
getch();
}
P a g e | 19

OUTPUT OF THE FOLLOWING PROGRAM:


P a g e | 20

11.To Print A Dynamically Allocated Stack Containing Names Of


Countries:
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include<process.h>
struct node
{
char country[20]; node*link;
};
class stack
{
node*top;
public:
stack()
{
top=NULL;
}
void push();
void pop();
void display();
~stack();
};
void stack::push()
{node*temp=new node;
gets(temp->country);
temp->link=top;
top=temp;
}
void stack::pop()
{
int temp;
if(top==NULL)
cout<<"UNDERFLOW!!!";
else
{
node*ptr=top;
top=top->link;
delete ptr;
}
P a g e | 21

}
void stack::display()
{node*temp=top;
while(temp!=NULL)
{
cout<<temp->country<<"->";
temp=temp->link;
}
cout<<"!!!\n";
}
stack::~stack()
{
node*temp;
while(top!=NULL)
{temp=top;
top=top->link;
delete temp;
}
}
void main()
{
stack st;
int ch;
while(1)
{cout<<"menu:\n1)push\n2)pop\n3)display\n4)exit\n";
cout<<"enter choice:";
cin>>ch;
switch(ch)
{
case 1:st.push(); break;
case 2:st.pop(); break;
case 3:st.display(); break;
case 4:exit(0);
default:cout<<"wrong choice entered";
}
}
}
P a g e | 22

OUTPUT OF THE FOLLOWING PROGRAM:


P a g e | 23

12.To Implement Dynamically Allocated Queue Contaning Names Of


Cities:
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include<process.h>
#include<math.h>
struct node
{
char city[20];
node*link;
};
class queue
{
node*rear,*front;
public:
queue()
{rear=NULL;
front=NULL;
}
void push();
void pop();
void display();
~queue();
};
void queue::push()
{
node*temp=new node;
gets(temp->city);
temp->link=NULL;
if(rear==NULL)
{
rear=front=temp;
rear=temp;
}
}
void queue::pop()
{
if(front==NULL)
cout<<"UNDERFLOW!!!";
P a g e | 24

else
{
node*ptr=front;
cout<<front->city<<"delete/n";
front=front->link;
delete ptr;
if(front==NULL)
rear=NULL;
}
}
void queue::display()
{
node*temp=front;
while(temp!=NULL)
{
cout<<temp->city<<"-";
temp=temp->link;
}
cout<<"===>\n";
}
queue::~queue()
{
node*temp;
while(front!=NULL)
{
temp=front;
front=front->link;
delete temp;}
}
void main()
{
queue qt;
int ch;
while(1)
{
cout<<"Menu:\n1)push\n2)pop\n3)display\n4)Exit\n";
cout<<"enter your choice:";
cin>>ch;
switch(ch)
{
case 1:qt.push(); break;
case 2:qt.pop(); break;
P a g e | 25

case 3:qt.display(); break;


}
cout<<"Menu:\n1)push\n2)pop\n3)display\n3)display\n4)Exit\n";
cin>>ch;
switch(ch)
{
case 1:qt.push(); break;
case 2:qt.pop(); break;
case 3:qt.display(); break;
case 4:exit(0);
default:cout<<"wrong choice";
}
}
}

OUTPUT OF THE FOLLOWING PROGRAM:


P a g e | 26

13.To Implement The Concept Of Multilevel Inheritance:


#include<iostream.h>
#include<conio.h>
class student
{
public:
int rollno;
void getdata()
{
cout<<"enter the rollno";
cin>>rollno;
}
};
class details:public student
{
public:
float total,m1,m2,m3;
void compute()
{
cout<< "enter the value of m1,m2,m3";
cin>>m1>>m2>>m3;
total= m1+m2+m3;
}
};
class show:public details
{
public:
void display()
{
cout<<"\n rollno="<<rollno;
cout<<" \n total="<<total;
}
};
void main()
{
clrscr();
show a;
a.getdata();
a.compute();
a.display();
getch();
P a g e | 27

}
OUTPUT OF THE FOLLOWING PROGRAM:
P a g e | 28

14.To Implement Concept Of Multiple Inheritance:


#include<iostream.h>
#include<conio.h>
class add
{
public:
int a,b ,c;
void getdata()
{
cout<<"enter the value of a and b";
cin>>a>>b;
c=a+b;
}
};
class sub
{
public:
int p,q,r;
void getinfo()
{
cout<<"enter the value of p and q";
cin>>p>>q;
r=p-q;
}
};
class add1:public add,public sub
{
public:
void display()
{
cout<<"\n addition of a and b ="<<c;
cout<<"\n subtraction of p and q ="<<r;
}
};
void main()
{
clrscr();
add1 a;
a.getdata();
a.getinfo();
a.display();
P a g e | 29

getch();
}
OUTPUT OF THE FOLLOWING PROGRAM:
P a g e | 30

15.To Implement Concept Of Single Level Inheritance:


#include<iostream.h>
#include<conio.h>
class B
{
int a;
public:
int b;
void get_ab();
int get_a();
void show_a();
};
class D: private B
{
int c;
public:
void mul();
void display();
};
void B::get_ab()
{
cout<<"Enter Values for a and b";
cin>>a>>b;
}
int B::get_a()
{
return a;
}
void B::show_a(){
cout<<"a= "<<a<<"\n";
}
void D::mul()
{
get_ab();
c=b*get_a();
}
void D:: display()
{
show_a();
cout<<"b= "<<b<<"\n";
cout<<"c= "<<c<<"\n\n";
P a g e | 31

}
void main()
{
clrscr();
D d;
d.mul();
d.display();
d.mul();
d.display();
getch();
}
OUTPUT OF THE FOLLOWING PROGRAM:
P a g e | 32

16.To Count The Total Numbers Of Characters Present In A Text File:


#include<fstream.h>
#include<conio.h>
void main()
{
clrscr();
int count=0;
char ch;
char str[]="welcome to c++.";
ofstream fout;
fout.open("string.txt");
fout<<str;
fout.close();
ifstream fin("string.txt");
while(!fin.eof())
{
fin.get(ch);
count++;
}
cout<<"no of characters present including spaces! are\n"<<count;
getch();
}
OUTPUT OF THE FOLLOWING PROGRAM:
P a g e | 33

17.To Count The Total Number Of Alphabet A Present In A Text File:


#include<fstream.h>
#include<conio.h>
#include<iostream.h>
#include<string.h>
void main()
{
clrscr();
char ch[2000];
int count;
ifstream fin;
fin.open("PRACTICAL.txt");
while(!fin.eof())
{
fin>>ch;
if(strcmp(ch,"A")==0)
count++;
}
cout<<"\n the number of alphabet 'A' is\n"<<count;
getch();
}
OUTPUT OF THE FOLLOWING PROGRAM:
P a g e | 34

18.To Count Total Number Of Blank Spaces Present In A Text file:


#include<iostream.h>
#include<conio.h>
#include<fstream.h>
void main()
{
clrscr();
ifstream fin("out.txt");
char ch;
int cnt=0;
while(!fin.eof())
{
fin.get(ch);
cout<<ch;
if(ch==' ')
cnt++;
}
cout<<"tot no of blank spaces:"<<cnt;
fin.close();
getch();
}
OUTPUT OF THE FOLLOWING PROGRAM:
P a g e | 35

19.To Count The Total Number Of Vowels In A Text File:


#include<fstream.h>
#include<conio.h>
void main()
{
clrscr();
ifstream fin("out.txt");
char ch;
int cnt=0;
while(!fin.eof())
{
fin.get(ch);
cout<<ch;
if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U');
cnt++;
}
cout<<"\n total no of vowels:"<<cnt<<"\n";
fin.close();
getch();
}
OUTPUT OF THE FOLLOWING PROGRAM:
P a g e | 36

20.To Count Total Number Of ? :


#include<iostream.h>
#include<conio.h>
#include<fstream.h>
void main()
{
clrscr();
ifstream fin("ABC.txt");
char ch;
int cnt=0;
while(!fin.eof())
{
fin.get(ch);
cout<<ch;
if(ch=='?')
cnt++;
}
cout<<"\ntotal no of ?:"<<cnt<<"\n";
fin.close();
getch();
}
OUTPUT OF THE FOLLOWING PROGRAM :
P a g e | 37

21.To Implement Function Overloading:


#include<iostream.h>
#include<conio.h>
void cube(int side);
void vol(int r,int h);
void rect(int l,int b,int s);
void main()
{
clrscr();
int side;
cout<<"enter the side:";
cin>>side;
cube(side);
int r,h;
cout<<"enter the radius:";
cin>>r;
cout<<"enter the height:";
cin>>h;
vol(r,h);
int l,b,s;
cout<<"enter the length:";
cin>>l;
cout<<"enter the breadth:";
cin>>b;
cout<<"enter the height:";
cin>>s;
rect(l,b,s);
getch();
}
void cube(int side)
{
int c;
c=side*side*side;
cout<<"volume of the cube:"<<c<<"\n";
}
void vol(int r,int h)
{
int k;
k=3.14*r*r*h;
cout<<"volume of the cylinder:"<<k<<"\n";
}
P a g e | 38

void rect(int l,int b,int s)


{
int z;
z=l*b*s;
cout<<"vol of rectangular box:"<<z<<"\n";
}

OUTPUT OF THE FOLLOWING PROGRAM:


P a g e | 39

22.To Swap Value Of Two Variable By Passing Pointers:


#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void swap(int * a, int* b)
{
int temp;
temp= *a;
*a=*b;
*b=temp;
}
void main()
{
int a,b;
cout<<"enter the first no";
cin>>a;
cout<<"enter the second no";
cin>>b;
cout<<"first no before swap:"<<a<<"\n"<<"second no before swap"<<b<<"\n";
swap(&a, &b);
cout<<"first no after swap="<<a<<"\n";
cout<<"second no after swap="<<b;
getch();

}
OUTPUT OF THE FOLLOWING PROGRAM:
P a g e | 40

23.To Implement Constructor Overloading:


#include<iostream.h>
#include<conio.h>
class deposit
{
float rate;
float total_amt;
long int principal;
int time;
public:
deposit();
deposit( long p,int t,float r);
deposit( long p,int t);
deposit( long p,float r);
void calc_amt();
void display();
};
deposit::deposit()
{
principal=time=rate=0.0;}
deposit::deposit(long p,int t,float r)
{ principal=p;time=t;rate=0.08;}
deposit::deposit(long p,int t)
{ principal=p;time=t;rate=0.08;}
deposit::deposit(long p,float r)
{
principal=p;time=2;rate=r;
}
void deposit::calc_amt()
{
total_amt=principal+(principal*rate*time)/100;
}
void deposit::display()
{
cout<<"\n principal: Rs."<<principal;
cout<<"\t period :"<<time<<"years";
cout<<"\n interest:"<<rate;
cout<<"\t total:Rs."<<total_amt<<"\n";
}
void main()
{
P a g e | 41

clrscr();
deposit d1,d2(2000,2,0.07f),d3(4000,1),d4(3000,0.12f);
d1.calc_amt();
d2.calc_amt();
d3.calc_amt();
d4.calc_amt();
cout<<"object 1\n";
d1.display();
cout<<"object 2\n";
d2.display();
cout<<"object 3\n";
d3.display();
cout<<"object 4\n";
d4.display();
getch();
}
OUTPUT OF THE FOLLOWING PROGRAM:
P a g e | 42

Q.24:Consider the Consignor & Consignee table & give SQL commands
TABLE : CONSIGNOR

CnorID CnorName CnorAddress City


ND01 R singhal 24,ABC Enclave NEW
DELHI
ND02 AmitKumar 123,Palm NEW
Avenue DELHI
MU15 R Kohil 5/A,South,Street Mumbai
MU50 S Kaur 7-K,Westend Mumbai
TABLE : CONSIGNEE
CneeID Cnor CneeName CneeAddress City
MU05 ND01 RahulKishore 5,Park Avenue Mumbai
ND08 ND02 P Dhingra 16/j,Moore New
Enclave Delhi
KO19 MU15 A P Roy 2A,Central/ Kolkata
avenue
MU32 ND02 S Mittal P 245,ABC Colony Mumbai
ND48 MU50 B P Jain 13 Block davilca New
Delhi

1. To display the names of all consignors from Mumbai.


Ans: Select CnorName from Consignor where city=Mumbai.
P a g e | 43

2. To display the cneeID,cnorName,cnorAddress,CneeName,CneeAddress for every


Consignee.
Ans: Select CneeID,CnorName,CnorAddress,CneeName,CneeAddress,from every
Consignor.Consignee where Consignor.CnorID=Consignee.id;
3. To display the consignee details in ascending order of CneeName.
Ans: Select * from Consignee Order by CneeName Asc;
4. To display number of consignors from each cities.
Ans: Select city,count(*) from Consignors group by city;
5. SELECT DISTINCT City FROM CONSIGNEE.
Ans:
Cneecity
Mumbai
New Delhi
Kolkata

Q.25:Consider the Sender & Receipent table & give SQL commands.
TABLE : SENDER
SenderID SenderName Sender Address Sender City
ND01 R jain 2,ABC Appts New Delhi
MU02 H sinha 12,Newton Mumbai
MU15 S haj 27/A Park Street New Delhi
ND50 T Prasad 122.K,SDA Mumbai
TABLE : RECIPIENT
ReeID SenderID ReName ReeAddress ReCCity
KO05 ND01 RBajpayee 5,Central Aveneu Kolkata
ND08 MU02 S Mahajam H6,A Vihar New Delhi
MU19 ND01 H Sing 2A,Andheri Mumbai
MU32 MU15 PK Swamy B5,CS Mumbai
ND48 ND50 S Triputhi 13,B1D Mayor Vihar New Delhi

1. To display the names of all senders from Mumbai.


Ans: Select * from Sender where SenderCity=Mumbai;
2. To display the reeID,senderName,senderAddress,ReeName,ReeAddress, for every recipts.
Ans: Select reeID,SenderName,SenderAddress,ReeName,ReeAddress,from Sender,Recipient where
Sender.senderID=Receipient RenderId;
3. To display the sender details in ascending order of SenderName.
Ans: Select * from Sender order by SenderName;
4. To display number of Recipients from each city.
P a g e | 44

Select Reecity,count(*)from Recipitent group by Reecity;

You might also like