SlideShare a Scribd company logo
1
AISSCE-2017-18
PRACTICAL RECORD
FILE
Programming Language & Database: C++ & SQL
Presentedby:
NAME : Vishvjeet Yadav
ROLL NO : 1623405
2
SCHOOL : THE SAGAR SCHOOL
3
INDEX
Sr No TOPIC Page No
1. Deletion In Array 3-5
2. Insertion In Array 6-9
3. Merging In Array 10-13
4. Binary Search 14-16
5. Linear Search 17-18
6. Selection Sort 19-21
7. Bubble Sort 22-24
8. Insertion Sort 25-27
9. Array Of Structure 28-30
10. Implementing Stacks Using Array 31-34
11. Implementing Queues Using Array 35-38
12. Implementing Stacks Using Linked Lists 39-44
13. Implementing Queues Using Linked Lists 45-50
14. To Write In A Text File 51-51
15. Data File Handling Using Classes 52-55
16. To find The Size Of A File 56-57
17. Copy Contents Of File To Another File 58-59
18. To Count Number Of Characters 60-61
19. To Count Number Of Words 62-63
20. To Read From Text File And Display It 64-65
21. Implementing constructors 66-68
22. INSERTION IN THE END OF LIST 69-72
23 DELETION FROM THE BEGINNING OF THE LIST 73-76
24. INSERTION IN THE BEGINNING OF A LIST 77-79
25. Reversing String 80-81
26. Ticket Booking System 82-84
27. Area Calculation 85-87
4
28. Pattern Based Program 88-89
29. Truth Table for XY+Z 90-91
30. Use of Class and Objects for storing Info 92-94
31. SQL 95
32. Creating Database 96
33. Creating Table 97
34. Inserting Elements into Table 98
35. Select all elements 99
36. To display selected attribute 100
37. To display distinct element of selected attribute 101
38. Using where clause 102
39. Using AND & OR 103
40. Using ORDER BY 104
41. Updating Table Attribute 105
42. Deleting a Record 106
43. Pattern Search 107
44. IN command 108
45. To Alter Table 109
46. View Command 110
5
C++
6
1.)Deletion In Array
#include<iostream.h>
#include<conio.h>
#include<process.h>
int lsearch(int[],int,int);
void main()
{
clrscr();
int a[50],n,index,x;
cout<<"enter the sizeof array(max50):";
cin>>n;
cout<<"enter elements of array:n";
for(inti=0;i<n;i++)
cin>>a[i];
cout<<"enter element to be deleted:";
cin>>x;
index=lsearch(a,n,x);
if(index==-1)
cout<<"element not found";
else
{
7
cout<<"element found at
index:"<<index<<",position:"<<index+1<<endl;
for(i=index;i<n;i++)
{
a[i]=a[i+1];
}
cout<<"updated array is:n";
for(i=0;i<n-1;i++)
{
cout<<a[i];
}
}
getch();
}
int lsearch(intar[],intsize,int x)
{
for(inti=0;i<size;i++)
{
if(ar[i]==x)
return i;
}
return -1;
8
}
9
2.)Insertion In Array
#include<conio.h>
#include<iostream.h>
#include<process.h>
int findpos(int[],int,int);
void main()
{
clrscr();
int ar[50],x,n,index;
cout<<"enter the number of elements in array:";
cin>>n;
cout<<"enter the elements of arrays:n";
for(inti=0;i<n;i++)
{
cin>>ar[i];
}
char ch='y';
while(ch=='y'||ch=='Y')
{
cout<<"nenter element to be inserted:";
cin>>x;
10
if(n==50)
{
cout<<"overflown";
exit(1);
}
index=findpos(ar,n,x);
for(i=n;i>index;i--)
ar[i]=ar[i-1];
ar[index]=x;
n+=1;
cout<<"continue?(y/n)";
cin>>ch;
}
cout<<"updated array:n";
for(i=0;i<n;i++)
cout<<ar[i]<<" ";
cout<<endl;
getch();
}
int findpos(inta[],intsize,int item)
{
int pos;
11
if(item<a[0])
pos=0;
else
{
for(inti=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;
}
12
13
3.)Merging In Array
#include<conio.h>
#include<iostream.h>
#include<process.h>
void merge(int [],int[],int,int);
void main()
{
clrscr();
int ar1[50],ar2[50],ar[100],x,n,m,index;
cout<<"enter the number of elements in array 1:";
cin>>n;
cout<<"enter the elements of arrays:n";
for(inti=0;i<n;i++)
{
cin>>ar1[i];
}
cout<<"elements of array 1 are: ";
for(i=0;i<n;i++)
{
cout<<ar1[i];
}
14
cout<<endl;
cout<<"enter the number of elements in array 2:";
cin>>m;
cout<<"enter the elements of arrays:n";
for(i=0;i<m;i++)
{
cin>>ar2[i];
}
cout<<"elements of array 2 are: ";
for(i=0;i<m;i++)
{
cout<<ar2[i];
}
cout<<endl;
merge(ar1,ar2,n,m);
getch();
}
void merge(int a1[],inta2[],intx,int y)
{
int mrg[100];
for(inti=0;i<x+y;i++)
{
15
for(intj=0;j<x;j++)
{
mrg[j]=a1[j];
}
for(intk=x;k<x+y;k++)
{
mrg[k]=a2[k-x];
}
}
cout<<"merged array is: ";
for(i=0;i<x+y;i++)
{
cout<<mrg[i];
}
}
16
17
4.)Binary Search
#include<iostream.h>
#include<conio.h>
int bsearch(int[],int,int);
void main()
{
clrscr();
int a[50],n,index,x;
cout<<"enter the sizeof array(max50):";
cin>>n;
cout<<"enter elements of array:n";
for(inti=0;i<n;i++)
cin>>a[i];
cout<<"enter element to be searched:";
cin>>x;
index=bsearch(a,n,x);
if(index==-1)
cout<<"element not found";
else
cout<<"element found at
index:"<<index<<",position:"<<index+1<<endl;
18
getch();
}
int bsearch(intar[],intsize,intx)
{
int f,l,mid;
f=0;
l=size-1;
while(f<=l)
{
mid=(f+l)/2;
if(ar[mid]==x)
return mid;
else if(x>ar[mid])
f=mid+1;
else
l=mid-1;
}
return -1;
}
19
20
5.)Linear Search
#include<iostream.h>
#include<conio.h>
int lsearch(int[],int,int);
void main()
{
clrscr();
int a[50],n,index,x;
cout<<"enter the sizeof array(max50):";
cin>>n;
cout<<"enter elements of array:n";
for(inti=0;i<n;i++)
cin>>a[i];
cout<<"enter element to be searched:";
cin>>x;
index=lsearch(a,n,x);
if(index==-1)
cout<<"element not found";
else
cout<<"element found at index:"<<index;
cout<<",position:"<<index+1<<endl;
21
getch();
}
int lsearch(intar[],intsize,int x)
{
for(inti=0;i<size;i++)
{
if(ar[i]==x)
return i;
}
return -1;
}
22
6.)Selection Sort
#include<conio.h>
#include<iostream.h>
#include<process.h>
int selsort(int[],int);
void main()
{
clrscr();
int ar[50],x,n,index;
cout<<"enter the number of elements in array:";
cin>>n;
cout<<"enter the elements of arrays:n";
for(inti=0;i<n;i++)
{
cin>>ar[i];
}
selsort(ar,n);
cout<<"sorted array:n";
for(i=0;i<n;i++)
{
cout<<ar[i]<<" ";
23
}
getch();
}
int selsort(inta[],intsize)
{
int sm,pos,t;
for(inti=0;i<size-1;i++)
{
sm=a[i];
pos=i;
for(intj=i+1;j<size;j++)
{
if(a[j]<sm)
{
sm=a[j];
pos=j;
}
}
t=a[i];
a[i]=a[pos];
a[pos]=t;
cout<<"narray after pass -"<<i+1<<"-is: ";
24
for(j=0;j<size;j++)
cout<<a[j];
}
return 0;
}
25
7.)Bubble Sort
#include<conio.h>
#include<iostream.h>
#include<process.h>
void bubsort(int[],int);
void main()
{
clrscr();
int ar[50],x,n,index;
cout<<"enter the number of elements in array:";
cin>>n;
cout<<"enter the elements of arrays:n";
for(inti=0;i<n;i++)
{
cin>>ar[i];
}
bubsort(ar,n);
cout<<"nsorted array:n";
for(i=0;i<n;i++)
{
cout<<ar[i]<<" ";
26
}
getch();
}
void bubsort(inta[],intsize)
{
int t,ctr=0;
for(inti=0;i<size;i++)
{
for(intj=0;j<(size-1)-i;j++)
{
if(a[j]>a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
cout<<"array after iteration-"<<++ctr<<"-is:";
for(intk=0;k<size;k++)
cout<<a[k]<<" ";
cout<<endl;
}
27
}
28
8.)Insertion Sort
#include<conio.h>
#include<iostream.h>
#include<process.h>
#include<limits.h>
void inssort(int[],int);
void main()
{
clrscr();
int ar[50],x,n,index;
cout<<"enter the number of elements in array:";
cin>>n;
cout<<"enter the elements of arrays:n";
for(inti=1;i<=n;i++)
{
cin>>ar[i];
}
inssort(ar,n);
cout<<"nsorted array is: ";
for(i=1;i<=n;i++)
cout<<ar[i]<<" ";
29
getch();
}
void inssort(inta[],intsize)
{
int tmp,j;
a[0]=INT_MIN;
for(inti=1;i<=size;i++)
{
tmp=a[i];
j=i-1;
while(tmp<a[j])
{
a[j+1]=a[j];
j--;
}
a[j+1]=tmp;
cout<<"array after pass "<<i<<" is: ";
for(intk=1;k<=size;k++)
cout<<a[k]<<" ";
cout<<endl;
}
}
30
31
9.)Array Of Structure
#include<conio.h>
#include<iostream.h>
#include<stdio.h>
structstud
{
int roll;
char name[21],grade;
float mark[5],t,avg;
}st[10];
void main()
{
clrscr();
int checkroll;
for(inti=0;i<10;i++)
{
st[i].t=0;
cout<<"enter the roll no.:";
cin>>st[i].roll;
cout<<"enter the name:";
gets(st[i].name);
for(intj=0;j<5;j++)
{
32
cout<<"enter the marks of subject"<<j+1<<" (out of
100):";
cin>>st[i].mark[j];
st[i].t+=st[i].mark[j];
}
st[i].avg=st[i].t/5;
if(st[i].avg<50)
st[i].grade='F';
else if(st[i].avg<60)
st[i].grade='C';
else if(st[i].avg<80)
st[i].grade='B';
else
st[i].grade='A';
}
cout<<"enter the roll no.:";
cin>>checkroll;
for(i=0;i<10;i++)
{
if(checkroll==st[i].roll)
{
cout<<"nnttStudent's result:";
cout<<"nroll no:"<<st[i].roll<<"nname:"<<st[i].name;
cout<<"ntotal marks:"<<st[i].t<<"naverage
marks:"<<st[i].avg<<"ngrade:"<<st[i].grade;
33
}
}
getch();
}
34
10.)Implementing Stacks Using
Array
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
class stack
{
int stk[5];
int top;
public:
stack()
{
top=-1;
}
void push(intx)
{
if(top > 4)
{
cout <<"stack over flow";
return;
35
}
stk[++top]=x;
cout <<"inserted" <<x;
}
void pop()
{
if(top <0)
{
cout <<"stack under flow";
return;
}
cout <<"deleted" <<stk[top--];
}
void display()
{
if(top<0)
{
cout <<" stack empty";
return;
}
for(int i=top;i>=0;i--)
cout<<stk[i]<<" ";
36
}
};
int main()
{
int ch;
stack st;
while(1)
{
cout <<"n1.push 2.pop 3.display 4.exitnEnter ur choice";
cin >> ch;
switch(ch)
{
case 1: cout <<"enter the element";
cin >> ch;
st.push(ch);
break;
case 2: st.pop();
break;
case 3: st.display();
break;
case 4: exit(0);
37
}
}
return 0;
}
38
11.)Implementing Queues
Using Array
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
class queue
{
int queue1[5];
int rear,front;
public:
queue()
{
rear=-1;
front=-1;
}
void insert(intx)
{
if(rear > 4)
{
cout <<"queue over flow";
39
front=rear=-1;
return;
}
queue1[++rear]=x;
cout <<"inserted" <<x;
}
void delet()
{
if(front==rear)
{
cout <<"queue under flow";
return;
}
cout <<"deleted" <<queue1[++front];
}
void display()
{
if(rear==front)
{
cout <<" queue empty";
return;
}
40
for(inti=front+1;i<=rear;i++)
cout <<queue1[i]<<" ";
}
};
main()
{
int ch;
queue qu;
while(1)
{
cout <<"n1.insert 2.delet 3.display 4.exitnEnter ur choice";
cin >> ch;
switch(ch)
{
case 1: cout <<"enter the element";
cin >> ch;
qu.insert(ch);
break;
case 2: qu.delet(); break;
case 3: qu.display();break;
case 4: exit(0);
41
}
}
return (0);
}
42
12.)Implementing Stacks Using
Linked Lists
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
class node
{
public:
class node *next;
int data;
};
class stack : public node
{
node *head;
int tos;
public:
stack()
{
tos=-1;
43
}
void push(intx)
{
if (tos < 0 )
{
head =new node;
head->next=NULL;
head->data=x;
tos ++;
}
else
{
node *temp,*temp1;
temp=head;
if(tos >= 4)
{
cout <<"stack over flow";
return;
}
tos++;
while(temp->next != NULL)
temp=temp->next;
44
temp1=new node;
temp->next=temp1;
temp1->next=NULL;
temp1->data=x;
}
}
void display()
{
node *temp;
temp=head;
if (tos < 0)
{
cout <<" stack under flow";
return;
}
while(temp != NULL)
{
cout <<temp->data<< " ";
temp=temp->next;
}
}
void pop()
45
{
node *temp;
temp=head;
if( tos < 0 )
{
cout <<"stack under flow";
return;
}
tos--;
while(temp->next->next!=NULL)
{
temp=temp->next;
}
temp->next=NULL;
}
};
main()
{
stack s1;
int ch;
while(1)
{
46
cout <<"n1.PUSHn2.POPn3.DISPLAYn4.EXITn enter ur choice:";
cin >> ch;
switch(ch)
{
case 1: cout <<"n enter a element";
cin >> ch;
s1.push(ch);
break;
case 2: s1.pop();
break;
case 3: s1.display();
break;
case 4: exit(0);
}
}
return (0);
}
47
48
13.)Implementing Queues
Using Linked Lists
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
class node
{
public:
class node *next;
int data;
};
class queue : public node
{
node *head;
int front,rare;
public:
queue()
{
front=-1;
49
rare=-1;
}
void push(intx)
{
if (rare< 0 )
{
head =new node;
head->next=NULL;
head->data=x;
rare++;
}
else
{
node *temp,*temp1;
temp=head;
if(rare>= 4)
{
cout <<"queue over flow";
return;
}
rare++;
while(temp->next != NULL)
50
temp=temp->next;
temp1=new node;
temp->next=temp1;
temp1->next=NULL;
temp1->data=x;
} }
void display()
{
node *temp;
temp=head;
if (rare< 0)
{
cout <<" queue under flow";
return;
}
while(temp != NULL)
{
cout <<temp->data<< " ";
temp=temp->next;
}
}
51
void pop()
{
node *temp;
temp=head;
if( rare< 0)
{
cout <<"queue under flow";
return;
}
if(front== rare)
{
front= rare=-1;
head=NULL;
return;
}
front++;
head=head->next;
}
};
main()
{
queue s1;
52
int ch;
while(1)
{
cout <<"n1.PUSHn2.POPn3.DISPLAYn4.EXITn enter ur choice:";
cin >> ch;
switch(ch)
{
case 1:
cout <<"n enter a element";
cin >> ch;
s1.push(ch); break;
case 2: s1.pop();break;
case 3: s1.display();break;
case 4: exit(0);
}
}
return (0);
}
53
54
14.)To Write In A Text File
#include<fstream.h>
int main()
{
ofstreamfout;
fout.open("out.txt");
char str[300] ="Time is a great teacher but unfortunately it kills all its pupils.
Berlioz";
fout << str;
fout.close();
return 0;
}
55
15.)Data File Handling Using
Classes
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<stdlib.h>
class student
{
char name[40];
char grade;
float marks;
public:
void getdata()
{
char ch;
cin.get(ch);
cout<<"enter name:";
cin.getline(name,40);
cout<<"enter grade:";
cin>>grade;
56
cout<<"enter marks:";
cin>>marks;
cout<<"n";
}
void display()
{
cout<<"nname:"<<name;
cout<<"ngrade:"<<grade;
cout<<"nmarks:"<<marks;
}
};
int main()
{
clrscr();
student arts[3];
fstreamfl;
fl.open("stu.dat",ios::in|ios::out);
if(!fl)
{
cerr<<"can't open file";
return 1;
}
57
cout<<"enter details for 3 studentsn";
for(inti=0;i<3;i++)
{
arts[i].getdata();
fl.write((char *)& arts[i],sizeof(arts[i]));
}
fl.seekg(0);
cout<<"contents of stu.dat are shown below.n";
for(i=0;i<3;i++)
{
fl.read((char *)& arts[i],sizeof(arts[i]));
arts[i].display();
}
fl.close();
return 0;
}
58
59
16.)To find The Size Of A File
#include<iostream.h>
#include<fstream.h>
#include<conio.h>
#include<stdlib.h>
int main()
{
long begin,end;
ifstreammyfile("stu");
begin=myfile.tellg();
myfile.seekg(0,ios::end);
end=myfile.tellg();
myfile.close();
cout<<"sizeis:"<<(end-begin)<<"bytesn";
getch();
return 0;
}
60
61
17.)Copy Contents Of File To
Another File
#include<fstream.h>
int main()
{
ifstreamfin;
fin.open("out.txt");
ofstreamfout;
fout.open("sample.txt");
char ch;
while(!fin.eof())
{
fin.get(ch);
fout<<ch;
}
fin.close();
fout.close();
return 0;
}
62
63
18.)To Count Number Of
Characters
#include<fstream.h>
#include<iostream.h>
#include<conio.h>
int main()
{
ifstreamfin;
fin.open("out.txt");
int count = 0;
char ch;
while(!fin.eof())
{
fin.get(ch);
count++;
}
cout<<"nNumber of characters in file are:"<<count;
fin.close();
getch();
return 0;
64
}
65
19.)To Count Number Of
Words
#include<fstream.h>
#include<iostream.h>
#include<conio.h>
int main()
{
ifstreamfin;
fin.open("out.txt");
int count= 0;
char word[30];
while(!fin.eof())
{
fin>>word;
count++;
}
cout<<"Number of words in file are:"<<count;
fin.close();
getch();
return 0;
66
}
67
20.)To Read From Text File And
Display It
#include<fstream.h>
#include<iostream.h>
#include<conio.h>
int main()
{
ifstreamfin;
fin.open("out.txt");
char ch;
while(!fin.eof())
{
fin.get(ch);
cout<<ch;
}
fin.close();
getch();
return 0;
}
68
69
21.)Implementing constructors
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class cabs
{
int cno,pkm,dist;
char type;
public:
cabs()
{
type='a';
cno=1111;
}
int charges(char x)
{
if(x=='a')
pkm=25;
else if(x=='b')
pkm=20;
else if(x=='c')
70
pkm=15;
else
cout<<"invalid option";
return pkm;
}
void reg()
{
cout<<"enter cab number:";
cin>>cno;
cout<<"enter city type:";
cin>>type;
charges(type);
}
void showcab()
{
cout<<"enter distance:";
cin>>dist;
cout<<"cab number:"<<cno<<"n";
cout<<"city type:"<<type<<"n";
cout<<"per kilo meter charges:"<<pkm<<"n";
cout<<"amount:"<<pkm*dist<<"n";
}
71
};
void main()
{
cabs obj;
obj.reg();
obj.showcab();
getch();
}
72
22). INSERTION IN THE END OF
LIST
#include<iostream.h>
#include<conio.h>
struct Node
{
int info;
Node *next;
}*start,*nptr,*temp,*rear;
Node *creat_nod(int a)
{
nptr=new Node;
nptr->info=a;
nptr->next=NULL;
return nptr;
}
void insert(Node*np)
{
if(start==NULL)
start=rear=np;
73
else
rear->next=np;
rear=np;
}
void display(Node*disp)
{
while(disp!=NULL)
{cout<<disp->info<<endl;
disp=disp->next;
}
}
void main()
{clrscr();
start=NULL;
char ch='y';
int item;
while(ch=='y'||ch=='Y')
{
cout<<"element to be inserted: "<<endl;
cin>>item;
nptr=creat_nod(item);
if(nptr!=NULL)
{
cout<<"node created"<<endl; }
74
else
cout<<"not created";
insert(nptr);
display(start);
cout<<"want to insert more? : "<<endl;
cin>>ch;
cout<<endl;
}
getch();
}
75
23) DELETION FROM THE
BEGINNING OF THE LIST
#include<iostream.h>
#include<conio.h>
struct Node
{
int info;
Node *next;
}*start,*nptr,*temp;
Node *creat_nod(int a)
{
nptr=new Node;
nptr->info=a;
nptr->next=NULL;
return nptr;
}
void insert(Node*np)
{
if(start==NULL)
start=np;
else
76
temp=start;
start=np;
np->next=temp;
}
void delet()
{
if(start==NULL)
cout<<"underflow"<<endl;
else
{
temp=start;
start=start->next;
delete temp;
}
}
void display(Node*disp)
{
while(disp!=NULL)
{cout<<disp->info;
disp=disp->next;
}
}
void main()
{clrscr();
77
char ch='y';
int item;
start=NULL;
while(ch=='y'||ch=='Y')
{
cout<<"element to be inserted: "<<endl;
cin>>item;
nptr=creat_nod(item);
if(nptr!=NULL)
{
cout<<"node created"<<endl; }
else
cout<<"not created";
insert(nptr);
display(start);
cout<<"want to insert more? : ";
cin>>ch;
}
ch='y';
while(ch=='y'||ch=='Y')
{cout<<"element to be deleted: ";
cin>>item;
delet();
display(start);
78
cout<<"want to delete more elements: ";
cin>>ch;
cout<<endl;
}
getch();
}
79
24) INSERTION IN THE
BEGINNING OF A LIST
#include<iostream.h>
#include<conio.h>
struct Node
{
int info;
Node *next;
}*start,*nptr,*temp;
Node *creat_nod(int a)
{
nptr=new Node;
nptr->info=a;
nptr->next=NULL;
return nptr;
}
void insert(Node*np)
{
if(start==NULL)
start=np;
else
temp=start;
80
start=np;
np->next=temp;
}
void display(Node*disp)
{
while(disp!=NULL)
{cout<<disp->info<<endl;
disp=disp->next;
}
}
void main()
{clrscr();
char ch='y';
int item;
start=NULL;
while(ch=='y'||ch=='Y')
{
cout<<"element to be inserted: "<<endl;
cin>>item;
nptr=creat_nod(item);
if(nptr!=NULL)
{
cout<<"node created"<<endl; }
else
81
cout<<"not created";
insert(nptr);
display(start);
cout<<"want to insert more? : "<<endl;
cin>>ch;
cout<<endl;
}
getch();
}
82
25) Reversing String
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
void main()
{
int j=0;
char c;
int d,e;
char str[100];
cout<<"ENTER STRING ";
gets(str);
d=strlen(str);
if(d%2==0)
{
e=d/2;
}
else
{
e=(d-1)/2;
83
}
for(inti=d-1;i>=e;i--)
{
c=str[j];
str[j]=str[i];
str[i]=c;
j++;
}
cout<<str;
getch();
}
84
26) Ticket Booking System
#include<iostream.h>
#include<conio.h>
#include<string.h>
voidmain()
{ clrscr();
int as,n,m=1,sn=1;
for(as=234;as>=0;)
{ start :
cout<<" ttt Available seats="<<as<<endl;
cout<<"tttEnter No.of Seatsrequired";
cin>>n;
if(n==0)
{ cout<<"ntttGetLost n";
goto start;
}
as-=n;
if(as<0)
{ cout<<" tt Not EnoughSeatsPlease EntervalidSeats";
as+=n;
cout<<endl<<endl<<endl;
goto start;
}
else
85
{ cout<<"n SeatNOS.are : ";
for(inti=0;i<n;i++)
{ if(sn>26)
{ sn=1;
m++;
}
cout<<m*100+sn<<" ";
sn++;
}
cout<<endl<<endl<<endl;
}
if(as==0)
{
for(intj=0;j<4;j++)
{ cout<<"tttt...House Full ...nn";
}
break;
}
}
getch();
}
86
87
27) Area Calculation
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<stdio.h>
voidarea(int);
voidarea (ints1)
{ cout<<" area of square = "<<s1*s1; }
voidarea (intl1,intbr1);
voidarea (intl1,intbr1)
{ cout<<" area of rectangle ="<<br1*l1; }
voidarea (float);
voidarea (floatr1)
{cout<<" area of circle = "<<(3.14*r1*r1); }
voidarea ( float,int,int);
voidarea (floatk,intb1,inth1)
{cout<<" area of triangle = "<<(k*b1*h1);}
voidmain()
{ clrscr();
//tofindthe area of variousgeomatrical shapesbyfunctionoverloading.
ints,l,br,r,b,h,ch;
cout<<"Enter ur choice forfindingareaof : n";
88
cout<<"1. Square n2 Rectangle n3. Circle n4. Triangle ";
cin>>ch;
switch(ch)
{
case 1 :
cout<<" enterside of square n";
cin>>s;
area(s);
break;
case 2 :
cout<<" Enter lengthandbreadthof rectangle n";
cin>>l>>br;
area(l,br);
break;
case 3 :
cout<<" Enter radiusof circle (infloatformat) n";
cin>>r;
area(r);
break;
case 4 :
cout<<" Enter base and heightof triangle n";
cin>>b>>h;
area(0.5,b,h);
break;
default:
89
cout<<" wrong choice !!!";
break;
}
getch();
}
90
28) Pattern Based Program
#include<iostream.h>
#include<conio.h>
#include<string.h>
void main()
{ clrscr();
for(inti=0;i<10;i++)
{ if(i==0||i==9)
{ for(intj=0;j<10;j++)
{ cout<<"* ";}
}
else
{ for(intk=0;k<10;k++)
{ if(k==0||k==9)
{cout<<"* ";}
else
cout<<" ";
}
}
cout<<endl;
}
91
getch();
}
92
29) TRUTH TABLE FOR XY+Z
#include<iostream.h>
#include<conio.h>
#include<string.h>
voidmain()
{ clrscr();
//WAPto printtruth table of XY+Z ;
intx,y,z,a=0;
cout<<" truth table forxy+z n";
for(inti=0;i<8;i++)
{ if(i<4)
x=0;
else
x=1;
if(i==0||i==1||i==4||i==5)
y=0;
else
y=1;
if(i%2==0)
z=0;
else
z=1;
a=x*y+z;
93
if(a==2)
a=1;
cout<<a<<endl;
}
getch();
}
94
30) Use of Class and Objects
for storing Info
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
class library
{int bno,price,btotal,bissued;
char auth[100],bname[100],pub[100];
public :
library(char dname[],char dauth[],chardpub[],intdp,intdn,intdbi,int dt)
{
bno=dn;
price=dp;
btotal=dt;
bissued=dbi;
strcpy(auth,dauth);
strcpy(bname,dname);
strcpy(pub,dpub);
95
}
~library()
{ cout<<"n Thanks. for using our program" ;}
void details()
{cout<<" ntttDetails of book : nnnn";
cout<<" Book name :tt"<<bname<<endl;
cout<<" Book no=tt"<<bno<<endl;
cout<<" Price of booktt"<<price<<endl;
cout<<" Total Books Availablet"<<btotal<<endl;
cout<<" Issued books : t"<<bissued;
cout<<" n Author :tt"<<auth;
cout<<" n Publisher :tt"<<pub;
}
library()
{cout<<" Hloon";}
};
void main()
{ clrscr();
char uname[100],uauth[100],upub[100];
int up,un,ubi,ut;
cout<<" Enter book name ,authors nameand publishers name :n";
96
gets(uname);
gets(uauth);
gets(upub);
cout<<" Enter book price , book no. , book issued books , total books:n";
cin>>up>>un>>ubi>>ut;
library a(uname,uauth,upub,up,un,ubi,ut);
a.details();
library b;
getch();
}
97
SQL
98
1.)Creating database
CREATE DATABASEEmployee;
99
2.)Creating table
CREATE TABLE Persons
(
PersonID int,
LastName varchar(255),
FirstNamevarchar(255),
Address varchar(255),
City varchar(255)
);
100
3.)Inserting elements into the
table
INSERT INTO Customers (CustomerID, CustomerName,
ContactName, Address, City, PostalCode, Country)
VALUES ('1','Cardinal','Tom B. Erichsen','Skagen
21','Stavanger','4006','Norway');
101
4.)Select all elements
SELECT * FROM Customers;
102
5.)To display selected attribute
SELECT CustomerName,City FROMCustomers;
103
6.)To display distinct elements
of selected attribute
SELECT DISTINCT City FROMCustomers;
104
7.)Using where clause
SELECT * FROM Customers
WHERE CustomerID=1;
105
8.)Using AND & OR
SELECT * FROM Customers
WHERE Country='Germany'
AND (City='Berlin' OR City='München');
106
9.)Using ORDER BY
SELECT * FROM Customers
ORDER BY Country, CustomerName;
107
10.)Updating table attribute
UPDATE Customers
SET ContactName='Juan';
SELECT * FROM customers;
108
11.)Deleting a record
DELETE FROM Customers
WHERE CustomerName='Alfreds Futterkiste';
SELECT * FROM customers;
109
12.)To search for a specified
pattern in a column
SELECT * FROM Customers
WHERE Country LIKE '%d';
110
13.)IN command
SELECT * FROM Customers
WHERE Country IN ('Finland','USA');
111
14.)To Alter Table
ALTER TABLE customers
ADD Age int;
ALTER TABLE customers
DROP COLUMN Age;
112
15.)View Command
CREATE VIEW Custom AS
SELECT *
FROM customers
WHERE Country='Finland';

More Related Content

DOCX
Pengaturcaraan C++ - Permarkahan (C++ Programming - Scores)
DOC
Practical Class 12th (c++programs+sql queries and output)
PDF
Function overloading
PDF
Regulasi kepegawaian
PPT
Unit 1 pengenalan teknologi dalam pendidikan
PPT
Teknologi Pendidikan - Reka Bentuk Pengajaran 1
PPTX
Presentation kajian lapangan
PPT
STL ALGORITHMS
Pengaturcaraan C++ - Permarkahan (C++ Programming - Scores)
Practical Class 12th (c++programs+sql queries and output)
Function overloading
Regulasi kepegawaian
Unit 1 pengenalan teknologi dalam pendidikan
Teknologi Pendidikan - Reka Bentuk Pengajaran 1
Presentation kajian lapangan
STL ALGORITHMS

Similar to Computer Science Practical Science C++ with SQL commands (20)

DOC
CBSE Class XII Comp sc practical file
PDF
DSC program.pdf
DOCX
code (1) thông tin nhập môn cntt hdsd.docx
PPT
Sparse Matrix and Polynomial
DOC
Sorting programs
PDF
C++ practical
PDF
Zoro123456789123456789123456789123456789
 
PDF
labb123456789123456789123456789123456789
 
DOCX
Data Structures Using C Practical File
PDF
COA_remaining_lab_works_077BCT033.pdf
PPTX
Structured data type
PDF
An overview of Python 2.7
PDF
A tour of Python
DOCX
Cs pritical file
PDF
Refer to my progress on this assignment belowIn this problem you w.pdf
DOC
programming in C++ report
PDF
Insertion Sort Code
PDF
Computer_Practicals-file.doc.pdf
CBSE Class XII Comp sc practical file
DSC program.pdf
code (1) thông tin nhập môn cntt hdsd.docx
Sparse Matrix and Polynomial
Sorting programs
C++ practical
Zoro123456789123456789123456789123456789
 
labb123456789123456789123456789123456789
 
Data Structures Using C Practical File
COA_remaining_lab_works_077BCT033.pdf
Structured data type
An overview of Python 2.7
A tour of Python
Cs pritical file
Refer to my progress on this assignment belowIn this problem you w.pdf
programming in C++ report
Insertion Sort Code
Computer_Practicals-file.doc.pdf
Ad

Recently uploaded (20)

PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Institutional Correction lecture only . . .
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
master seminar digital applications in india
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
RMMM.pdf make it easy to upload and study
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Presentation on HIE in infants and its manifestations
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
human mycosis Human fungal infections are called human mycosis..pptx
Institutional Correction lecture only . . .
Final Presentation General Medicine 03-08-2024.pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
VCE English Exam - Section C Student Revision Booklet
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
master seminar digital applications in india
Abdominal Access Techniques with Prof. Dr. R K Mishra
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
RMMM.pdf make it easy to upload and study
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
2.FourierTransform-ShortQuestionswithAnswers.pdf
Microbial diseases, their pathogenesis and prophylaxis
O5-L3 Freight Transport Ops (International) V1.pdf
Presentation on HIE in infants and its manifestations
Ad

Computer Science Practical Science C++ with SQL commands