0% found this document useful (0 votes)
15 views22 pages

Adobe Scan 1 Nov 2023

Uploaded by

savksarvesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views22 pages

Adobe Scan 1 Nov 2023

Uploaded by

savksarvesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

else

l pro ?1 an1~ list cout<<ele<<" does not exis ( <<end!;


1 H,J
q., fp void main()

{
r11 h frequency fl;
Cla fi-l 'jU< n, Y clrscr();

fl.ge tda ta();

Int I\ cli:, f. 1100], fl.find();

public fl. putrla ta();

void getrla ta(); gett:h();

void find(); }
void putrl.a ta( ) ,

}; Output 1: Output 2:

void frequency:: get.data(} Enter the size of the array Enter the size of the array

5 5
{
Enn,r the array elements Enn,r the array elements
cout<<' Enter the size of the array" «end!;
-1 1
cin>>n;
cout<<" Enn,r the array elements" <<end!; 23 2

783 3
for( int i=O; i<n; i++)
-1 4
cin»a[i];
coul<<" Enn,r the search element" <<end!; 2 4

Enn,r the search elementEnn,r the search element


cin>>ele;
-1 7

Frequency of -1 is 2 7 does not exist


void frequency:: fina()

2) Write a CH· program to insert en element i'lto an array at a given positlm.


f=O;

for( int i=O; i<n; i++) #include<iostreamh>

il(a[i]==ele) #include<conio.h>

f++; #include<process.h>

#include<iornanip.h>
?
void frequency:: putdata()
class insertion

ii( f>O) {
cout<<" Frequency of • <<ele<<" is • <<f<<endl; int I\ a [1001 ele, p;
cout<<" The array a fter Inser ti on is"<<endl;

for(intf=0; i<n; I++)

cout«setw( 4) «a (I);

void main( )

lnserdon i;
Ul Enter th numb< r ol I ment. < cndl ;
clrscr();
Jn n.
l.getdati( );
, ,urn" llnltr I.he arr.iy , lcrn:nr • <<: 11dl,
I.Insert();
, ..
for(lnt 1=0, l<n; l++J

cln>--a(IJ; f.putdata( ),

cout<<" Enll!r the element ID be Inserted· <<endl; getch() ;


cln>>ele;
cout<<" Enter the position from 0 lo "<<n<<endl; Output 1: Output 2:
cin>>p; Enter lhe number of elements

5
void insertion:: lnserl() Enter the array elements
1
11(p>n II p<0) 2

3
cout<<p<<" is an Invalid position" <<endl; 4
getch[ ); 5
exit(O); Enter the element to be inserted
6
else Enter the position from Oto 5
0
for (int i=n-1; i>=p; i-) 6 is successfully inserted
aP+l]=ap]; The array after inserti on is
a(p)=ele; 612345
n=n+l;

cout<<ele<<" is success fully inserted" <<end!; 3) Write a C++ program to delete ai element from ai array from given pos~lai .
#i nclude <iostreamh>

#i nclude<conio.h>
void insertion:: putdata( J
#i nclude<iomanip.h>
void deletion :: putda ta[ )

cout<<" The array aflEr deletion Is" <<end!;

I l for(i=0;i<n;i++)
\I 1 l iY: { ), cout«setw( 4) <<a [I];

vc.. l r ,td:Jt:,( J,
void main( )

void d luUon ruld,i~' )


deletion d;
clrscr( ) ;
cout<<" Entc, the nun,b~r of clenrnts <<endl;
dgetdata( );
cln>>n;
dremove( );
couL<<" Entcr the army clements" <<cndl;
dputdata( );
for (i=0; i<n; l++)
gctrh();
cin»a[i];

coul<<" Enter tlie position from Oto • «n-l<<cndl;


Output 1:
cln>>p;
Enter the number of elements
5
void deletion:; remove( )
Enter the array elements
1
lf( p>n-1 11 p<0]
2

3
cout<<p<<" is an invalid position" <<endJ; 4
gett;h( ), 5
exit(0);
Enter the position from Oto 4
4
else
The element 5 at position 4 is successfully removed
The array after deletion is
1 2 3 4
cle=a[p];
for(i=p; i<n; i++)
4) Write a C++ program to sort the elements of an array in ascending orderusblg tisertlon sort.
a[i)=a[t+l);
#include<ios tream h>
n=n-1;
#include<conio.h>
cout<<" The element "<<ele<<" at position • <<p<<" ts successfully removed" «end!;
#include<iomanlp. h>
}
class sorting
H

void main( )
U I

sordng s;
void rn IJnl! 1 1J..t,1 ) clrscr( ) ;
s.gerda ta( );
cou1,<"Ent, 1 th ~"mb 1 rifclrmc'nlS"<<cndl, ssorl( );
cm>>n; s.putda ta( ) ;
...
cout<,... Pntcr the "r 1y, It me nts" <<cndl, gelX:h( );
for(lnt 1-0,l<n;I+ ➔)

cln»a(l]; Output 1.
EntEr the number of elements
void sorting:· puldata( ) 5
{ ' Enter the array elements
cout<<"The array after sorting is" <<endl, -999
for(lnl l=O;i<n;i++) 0
cout«sctw( 4) «a (I]; -23
6

void sorting:: sort( ) -5

The array after sorting IS


Int temp,J; -999 -23 -5 0 6

for(lnt i=l;, i<n; I+•)

5) Wrte a C++ program to search/or a given element ti ai array usrig bin rry search method

j=i; #include<iostreamh>

while(j>=l) #lnclude<eonio.h>

class binarysearch

il(aOJ<aO-lD
int a[100), n, ele, loc;

temp=aO); public:

aOJ=a0-1J; void getdata( );

afi-l)=temp; void search( ) ;

void putrlata( );
else
Id)
b mid+l;
C

fo lint 1 0 vndl;
n, l+t)
cln>, I•). void main( )

rout<<" Ent.er the i:c:irch elC'mcnl" <<enctl


bl narysearch b;
c1n>>clc,
) clrscr( );

b.getdata( ) ;
void blnarysearch :· putda1a( )
b.search( ) ;
{
b.putx:lata( );
il(loc >= O) getch( ),

cout<<" Element found at position


"<<loc+l; Output 1:
else

Enter the number of elements


cout<<" Search is unsuccessful" <<endl;
5

Enter the array elements


void binarysearch :: search( )
-1
0
int b, e, mid;
45
loc = -1;
67
b= O; 78
C = n-1;
Enter the search element
while( b<=e)
. 0

Element found at position 2

mid= (b + e)/2;
ii( ele =a[mldD 6) Wr.i'.e a C++ program to create a class with data members principle, timeimdrate. 0-eatemmiber
fan ct ions to acce~ da:a vahJes tocomµitcstmple mterest mdto display the resut.
#include<iostreamh>
loc = mid;
#include<conio.h>
break;
class interest

else
private:
If{ ele<a[midD
double p, t r, sl;
e = mid-1; public:
Time: 3

Rote: as
Simple lncerest 2550

7) Write a c++ program to create a class with data members a, 4 c ondmember Jindlonstolnput dat."
c0t11pitet he dfscrimln ant based on lhe following conditions and print the root.s

u lfdlscrfm•• a11t =Othen prb1t roots areeqial


rf}f 1pl Hn HJr•~ tl•nc ( ndl,
cm lfdfscrfmb1 ant> Othen print roots are r eal
L '•
lfdiscrfmilont <Othen print roots are Imaginary.

vn1d 1nlf, c t r•&.1td.J1J1 ] 1/lnclude<iosu-cam h>

1/lncludc<conlo. h>

cou1,< Pr trx.lplc amount: • <<p<<endl; Ill nc Jude <process. h>

cout<<"Tirre· "<<t<<endl; 1/lnclude<math.h>

cout<<" Ibo:,: • <<r<<cndl; class quadra lie

cout<<"Simple ino:,rcst: "<<:si<<endl;


lloa t a,b,c,rl,r2.x;

void interest .; compute( ) public:


void gctdata( );

si = ( p • t• r)/100; void calculate( );


void putdata( );

void main( J };

void quadratic :: getdata( )

interest i;

clrscr( ); cout<<" Enter three co-efficients" <<end!;

i.getdata( );

i.compute( ) ;
. cin>>a>>b>>c;

i.putdata( ); void quadratic :: calculate( )

getch( ); {

x=b•b-4•a•c;

Output 1: if(x=O)

Enter principle amount time, rate {

10000 cout<<" Roots are equal" <<endl;


3 rl=( -b-sqrt(x) ) / ( 2'"a );
8.5 r2=rl;
Principle amount: 10000
Second root=•l Second rooe=0.5

8) Wrf:e a C++ program to fin dthe area of a scp are, rectm g/e, trlmgle using jirnalan overlaadlng.
dll r r, ndl,
lllnclude<lostreamh>
/(Z' J.
1/lnclude<eonlo.h>
1. I b rt J , / ( l! ).
lllnclude<math.h>
class funoverload
C

floats;
cout<<" Roots are um gt nary" «e ndl; public:
getrh( ); double area( double a)
exit( OJ ;

return a*a:
void quadratic :: put.data( )

double area(doublc L double b)


cout<<" First root=" <<r 1 <<end!;
cout<<"Second root=· <<r2<<endl; return l"b;

void main( ) double area( double a, double b, double c)

{
quadratic q; s ={a+b-+c)/20;

clrscr( ); return (sqrt(s4(s-a)"(s-b)"(s-c)));

q.getdata( );

q.calcula te( ) ; };

q.putrlata( ); void main( )

gell:h( ); {
double x, y, z;

Output 1: Output 2: Output 3: int ans;

Enter three co-efficients Enter three co-efficients Enter three co-efficients funoverload f;

1 1 2 clrscr( );

2 2 -3 cout<<" lSquare" «end!;

3 1 1 cout<<" 2 Rectangle" <<end!;

Roots are imaginary Roots are equal Roots are positive and different cout<<" 3. lrlangle" «end!;

Firs troot=-1 Firstroot=l


2
Art'll ol lhu triangle• 2.904738

'JJ w,-,,,,,c++vroorrtm tof111dt 1,ccu be of a number usklo In lilepnct./al.


I , th II

In
""· Ill nc lud,•<los trea m h>

1/lndudr.<conlo.h>
•ut Ar , r,J lh · ,11~,rr <<[drva(xJ< cndl,

Inllne Int square ( Int a)


c.bt

If[ ans,,:2)
rclurn(a•o'a);

cout<<' Enter two sides" «end!;


Int main[)
ctn>>x>>y;

cout«"Area of the reccrngle=" <<[area(x.y) <<endl;


lntx,y;
x:s quare( 5);
else
cout<<"Square of 5 = • <<X<<endl;
ll(ans=3)
ycsquare( 10);
{
cout«.''Square of 10 "• <<y<<endl;
cout<<" Enter three sides"<<endl; reO.trn O;
cin>>x>>y>>z;

cout<<"Area of the triangle=• <<[area(x, y, z) <<end!; Output 1: Output 2:


Square of 5 = 25
else
Square ofl0 = 100
cout<<" Invalid choice" <<end!;
10) Write a C++ program tofindthe sum ofseries 1 +x +x2 +-.+musing caistruct~.
getrh( ); #include<iostream h>

#include<math.h>
Output l; #include<eonio.h>
lSquare class series
2. Rectangle
3.lrlangle Int x, n. sum;
Enrer your choice public:
3
serles(int b, Int p)
Enrer three sides

4
x=b;
3
n=p;
cL1ss student

private:

(' long Int rollno;


char name[20];
IJI , 1,
public:
fer( IOI I l I n, IH)

um SU"l t pOW(X. I). void gctda ta( )


rctur.n sum;

cout<<" Enter roll number and name" <<endl;


void main( )
cf n>>roll no>>na me;

Int x. n;
void putda ta( )
clrscr( );

cout<<" Enter the value for x' <<endl; cout<<" Foll number=" <<rollno<<endl;
cin>>x;
cout<<" Narre=" <<na me<<endf;
cout<<" Enter the value for n• <<endl;
cin>>n;
);
series s(x. n);
class rrarks : public sb.Jdent
series sl=s;

cout<<" Sum ofseries=• <<Sl.cafculate() <<end!;


private:
geo::h( );
int ml;
int m2;
Output 1: Output 2:
int total;
Enter the value for x
public:
2
void read( )
Enter the value for n
5
cout<<" Enter the two subject marks" <<endl;
Sum of series=63
cin>>ml>>m2;

total=ml+m2;

11) Wri'.e aC++programtocrea:ea baseclasscontcmtigthe da:am embers roll num ber ai dnam e.Also
void print( )
crea:e a member jlnctlon to read a,1 d display the da:austzgthe caice,t: ofsingle in hertaice. lreate a
derived class thee ccntalnsmarks oftwo subjects at1 dt«al marks as the data members.
#fnc!ude<iostreamh>
cout<<"Subjectl marks ='<<ml<<endl;
#fnclude<conlo.h>
cout<<"Subject2 marks :c"<<m2«endl;
I!,

noat fees;
public:
void getdata();
void put.data( );
};
, Ir , , ( void student :: get.data( )

m td:!t.1[ J.
nu id( J, cout<<" Enter student register number" «end!;
cln>>regno;
niputd.1m( );
cout<<" l!nter student name" <<endl;
rnpr!nt( ),
cln>>name;
gelCh( J;
cout<<" Enter student fees" <<endl;
cln>>fees;
Output 1:

Enter roll number and name


void student :: putdata( )
161001
aniar
cout<<" Student register number=<" <<regno<<endl;
Enter the two subject marks
cout<<"Student name=" <<name<<endl;
90
cout<<" Student fees=" <<fees;
85

Roll nurnber=l61001 void main( )


Name=amar

Subject! marks=90 student s, •sp;


Subject2 marks=85 clrscr( ) ;
Total marks=175 sp =&s;

sp->getxlata( );

1Z) Wrte a C++ program tocrer1e a class contain ingthe following data members register number, name sp->putda ta( ) ;
an dfees.Al5ocreate a member junction to read and display the datausingtheconcefL ofpointersto
getch( );

#include<iastreamh>
Output!:
#include<conio.h>
Enter student register number
class student
161001

Enter student name


private:
amar
long int regno;
Enter student fees
char name[20];
1001
II{ ll>pl•-1)

rnut<<'\l S=<:kcont,ln; ";

13)
-- --- - --------- ----- ---~----------------
Wrte a C++ pronram to per/om, Pl/SH operutJo,, a,, t11ck
#inciude<1Clf.tream.h,. ----------------------------
for( Int , .. o. c<■ r,:,p; c <-+)
cout<<a (c )<<"

cout<:<endl;
•;

lt1nclude<con10. h>

llinclude<process.h>
else
#include<ctype. h> cout<<"Stick Is empty• <<eTicil;
#define MAX 5
class stack. );

void rmin( J
int a[MAX);

mt top; stack s;

clrscr( );
char choice;
char choice;
public:
int elc;
stack( )
s.prinl( );

cout<<"Doyouw.inttopushanltem( Y/N)? •
top=-1;
cln>>cholcc;

while( touppcr( choice) ='V,


void pusb(int item)
{
cout<< Entcr the itelTt •:
if{top=MAX-1) cin>>elc;
{ s.push(cle);
cout<<endl<<"Stack Is full" <<end!; s.prlnt();
getch( ); cout<<"Do you want to push another ill!m ( Y/N ) 7 •:
exit( O); cin>>c ho lee;

top++;

a[top)=ltem; Output

cout<<ltem<<" Is pushed •«endl; Stick Is empty


} Do you want to push an ltem(Y/NJ? Y
void print( ) Enrer the ltl?m: 1

l ls pushed

MIIIDPE'fltP'P!PYfffl'fffW«fRl«IW«rWltrfMmOe<ecvcz Ill Q
void push(lnt Item)

D 111,1~/Nl'Y

If( top==MA X-1)


2 l pi, h r1

tack tont llrt'. I l cout«cndl<<"Stack is full" <<end!;


no you w.101 ~, pu,h ~nothcr 1wm (Y/N)? Y return;
En1er th~ Itr m 4
4 Is pushed
top++;
Stackcont11ns l 2 4
a(top)=ltem;
Do you want ID push another item {Y/N)7 Y
cout<<item<<" is pushed" <<endl;
Enti,r the llem: 5
5 IS pushed
void print( )
Stack contains 1 2 4 5
Do you want 1l'.> push another ilem(Y/N)? Y
lf(top!=-1)
Enti,r the item: 6
6 is pushed
cout<<"\tStack contains";
Stack contains 1 2 4 5 6
for(lntc=O; c<=top; c++)
Do you want ID push another item(Y/N)? Y
cout«a [c ]<<" ";
Enter the ilem: 8
cout<<endl;
Stack is full

else
14) Wrte a C++ program to POP elements /i-cxn the stack
cout<<"Stack is empty''<<endl;
#include<iastreamb>
#include<conio.h>
void pop( )
llinclude<ct;ype.h> ,

#define MAX 5
if( top==-1)
class stack
{

cout<<endl<<"Stack is empty" «end!;


int a(MAX);
return;
int top;

public:
else
stack( )

Int data=a[top];
top=l;
top-;

cout«data<<" is popped' «endl;


Stack Is empty

15) Wr~e aC++ pro9ram to perform enqJeueanddec,ieueoper«lms.


//lncludc<lostrcamh>
t I
lllncludc<conlo.h>
LT(
//lncludc<lomanlp.h>
.print( ),
cl.1ss queue
s.push( 1);

s. p-anl( ), int q[101 Cr;


s.push( ·2); Int x. ele;
s.prlnl( ); public:
s. push( ·3); void enqueue(ln~;
s.irinl( ); void dequeue( );
s.pop( ); void dis play( ) ;
s.p-int( ); queue( )
s.pop( );

s.irint( ); f=O;

s.pop( ); r=O;

• S.Jrint( );
};
gerrh( );
void queue:: enqueue(lnt x)

Output:

Stack is empty il(r>3)

-1 is pushed cout<<"Queue overflow "<<endl;


else
Stack contains -1
-2 is pushed

Stack contains -1 -2
r++;
-3 is pushed
q(r)=x;
Stack contains ·1 -2 -3
-3 is popped cout«endl«q[r)«" is inserted' «endl;

Stack contains ·1 -2
-2 ls popped
void queue :: dequeue( )
Stack contains ·1
-1 ls popped
lf(r=O)

nrns e eze
ql.dlsplay( );
ql.dequeue( );
ql.dlsplay( );
qt.dequeue( );
ql.dlsploy( );
f 0,

gctch( );
r fl;

else
Output
f++;
Que uc under now

eJe=qff); 3 ls lnserll.!d
Queue contains: 3
cout<<endl<<ele<<" is deleted" <<end!;
4 ls Jnscrted

void queue display( J Queue contains: J 4


5 ls Inserted

11{r=()
Queue contains: 3 4 5
3 ls deleted
cout<<"Queue underflow "<<end!;
Queue contains: 4 5
else
4 ls deleted
• cout<<"Queue contains: ·;
Queue contains: 5
for(int i=f+l; l<=r; i++)
5 is deleted
cout«setw( 4) «qp];
Queue underflow

void main( J
16) Wr.te a C++ prooram to create a linked list and appending nodes.
#include<iostreamh>
queue ql;
#include<conio.h>
clrsa( );
class linklist
qldJsplay( );

qlenqueue(3);
struct node
qldisplay( );

ql.enqueue( 4);
int data;
qldisplay( );
node •link;
q lenqueue( 5);
}•start;
qldisplay( );
public:
ql.dequeue{ );
llnklis I( ) ;
riumJ cout<<endl<<num<<" Is inserted as the first node"<<endl;
nt[ )

else
II 11 ti I r>1 11 it l

node •temp =start;


1,1ft NUii, whlle(temp->llnk!=NULL)
temp=temp->link;
Vold lmklL-:t prml{ ) temp->link=nnode;
cout<<endl<<num<<" is Inserted" <<end!;

lf(star~=NU LL)
{
void llnkllst :: count( )
cout<<" Linked list is empty" <<endl;
relllrn;
node •temp;
int c=O;
cout<<" Linked list contains" <<endl;
for(temp=start; ll!mp!=NULL; ll!mp=temp->link)
node • temp=astart;
c++;
while(temp!=NULL)
cout<<endl<<"Number of nodes in the linked list:'°<<c<<endl;
{

cout<<te mp->da ta<<" "


void main( )
temp=temp->link;

linklist •obj=new linklisl{ );


clrscr( ) ;
obj->print( ) ;

ohj->apµend( 100);
void linklist :: append( int num)
,1h1->print( ) ;

001 ->count( ) ;
node •nnode;
ohj•>append( 200);
nnode=new node;
ob1->print( ) ;
nnode->da ta=num;
obj->count( );
nnodc->link=NU LL;
obj->a ppcnd( 300);

obj->print( );
ll[start==NULL)
obj->count( );
{
getr:h( );
start= nnode;
For more than 100 uni IS Rs 5.50/ unit
6) Com puted ueda teas bill dat~ lS
days
7) Llsl all the bills gener ated

I I l d I• ' •r H

ll/11 Solution
1) Command tocre ateta ble
N "'"" 1 ·I n"d Ir, Lil h,d d If trl
lOOI ln,,rt cd create table ebill

Ltnk •d 11!.L• •>ntll rr.

100 200 rrn v.irchar2(10),

Number of nodes In the linked hst,-z cname v.irchar2(20),

300 IS inser ted blll_date date,

Linked Jistco ntaln s units int

100 200 300 );

Numb er of nodes m the linked list~3


Th ble create d.

2) Command to inser t 10 recor ds intot


beta ble
SQL Pro blem s list (Ex per ime nt num
ber 17- 20) inser t into ebill value s('a23 45','K irshn a','12
-mar- 2016 ',31);
Exp erim ent num ber 17: 1 row(s ) inser ted
Gene rate the elect ricity bill
1) 0-cat c a table with the follow ing
fields ins ert in to ebill v.ilue s('b56 78','V ittal', '12-m ar-20
16',50 );
Fick! Nam e T:we 1 row(s) insert ed
RR numb er v.irchar2( 10)
Consumer name varch ar2(1 0)
inser t into eblll v:ilues ('c43 21','P andu' ,'12-m ar-20
Bill Date date 16', 75);
• I
Uruis int
- -- l l'l>W(s) Inserted.

l) bser t 10 recor ds lntoth etal.J le. nsert 1:,tn 1'bill ,,alu ·s('a4 567',' Appu rao','1 2-ma r-201
6',12 0);
3) <hec k the struc ture ofthe tahle . l ro·At~l inser ted
4) Add the following field stoth etabl
e
Field name Data t e inser t into ebill value s('c21 21','R
Bill amou nt aghu' ,'12-m ar-20 16',63 1);
float
Due date 1 row(s ) inser ted
date
inser t into ebill value s('a45 32','R
ani,'1 2-ma r-201 6',13 1);
S) Com putet hebil l amou nt for each
custo mer aspe r follow ing rules 1 row(s ) inser ted
Minim umam ount: Rs 50

For firstl OO unllSRs 4.50/ unit


inser t into ebill value s('c23 56','M
uralr; 12-m ar-20 16',5 16);
u ( t 7(, • rlh3rl '12 rmr-2 016', 673):
6) Comm and tocal culat edue datea
sbilld ate+ 15 days
updall! ebUI set due_date=bill_da
tc+lS;
II I l In 10 row(s ) updat ed
'111 v.,I ( 'c625 3','Nu raynn a'.'l2- m,r. 20l 6',
'r
90):
\lo. ) Irr r d
7) Comm and to list all the bills gener
ated.
selec t • from ebill;
II t Into el' I val
Ct
U!" ('b87 63"
,gopa la'.'12 -mar- 2016 ',450 );
RR N
1 row( ) I 11:;cr tcd. ----~CU A.ME
----' --..,. ._;.. ;..... =....... __........~..,._
a234 5 ,
Kitsh na
b567 8 Vitta l 12-M AR-1 6 50 275
3J Comm an d lo chec k the struc ture c4.32 1
ofthe tab le Pand u 12-M AR:1 _6 75 387. 5-•
d esceb lll; a456 7 Appu rao 12-M AR-1 6 120 610
0

c212 1 = R~ _ 12-M AR-1 6 631 3420 .5


a453 2
c235 6
-
Ram
Mura li
-- -~ -
-~ -
12-M AR-1 6
12-M AR~1 6
131

670.5

o.,.
20

~
b876 5
..
~
Sriha ri 12-M AR-1 6
~ - ..,. 516
673
2788
3651 .5
27-M A

✓ 27-M
Numti. r c625 3 Nara yana 12-M AR-1 6 90 455
✓ gopa la 27- -
~---'---------------'--2425
- ; 2 ._M_A
-- -
b876 3 _._
- . . 27•M O__ j
R.:_1_6 __- -

--- -·- ------'-™_


~0 - -
, -4
..:.....-;._;.J
4) Com mand to acid the follo wing
fiekl stotb etab le Exp erim ent 18
Field nam e T e Crea te a stude nt datab ase and comp
Bill a mo un t uteth eresu lt
Num ber
Due date 1) Creat e a table for a class of stude
Date nts with the follow ing detai ls
Field nam e Data tvoe
alter tablec bill add (bill_ amtn umbe Stu dent ID int
r( 4,4), due_d ate date) ;
Stude n t name varch arUS 0)
Tobie altere d
Phy sics int
Ch em istiv int
Math em atics int
5 ) Comm an d t.>rnlcul,'!! ei. .ll :un O'll't
:?.s per foll.:> wiugr ules Co mput er scien ce int
a) updat e cbill set h,11 ,mt:=.,,l Kann id a int
En glish int
10 r ow( s) upda red. 2) Add 10 records for stude nt ID, stude
nt ncme llTldmar/cs ofsix.subjects usti9 inser t canm cnd.
3) Dsplay the descri,xion oft he fields
in the table using desc ccmm ai d
b) upda te ebill set bill_amt:=bill_am 4) Alter the table toca /cult ietot al
l + 100• 4.50 + (unit s-100 ) *5. 50 wher e aid perc ent~ emcr ks.
uni ts>l 00;
6 row(s) upda ted 5) Com p,ter tlie resu t as 'pass' or Tail'
bych eckin gifth estud ent has scor edmc rethm 35mc:rks ti eacr.
subject.
6) Listt he car tents ofthe table.
c) upda te eblll set bill_a mt=b lll_am
t + units* 4.S0 wher e units <=l0 0;
7) Retri eve aUth e cm tents oft he table
4 row( s) upda ted .
8) Retri eve oo /y stude nt id at d stude
nt nane of all students.
I ha r rult a, 'pan'

hu ha• r II It a< 'fair Insert into srudent values( 1128,'Murali',67,35,54,23,65,65);

) ,,,, r numba ofst:11~u who have f><l5SE'tl. 1 row(s) Inserted


I I '"'-•Ill ti r,11mf,cr ofstudents who lwve follcd.

I 1 ll t tf fll<k71t5 who have percc11togc orculer l/11a1 60. insert into student values(1102,'harish',89,34,54,4S,53,67);
14/ ort t/11: t o/,/c occord1J1otothc ore/er ofstudc11t ID. 1 row(s) Inserted

Soiul1011 Insert Into student values( 1104,' mahesh',56,43,89, 75, 93, 78];
1 J Command to create a table
1 row(s) inserted
crca11:- !able student

Insert into srudent values(1114,'abhay',79,24,64,85,43,57);


Sid int, 1 row(s) inserted
sn.:ime varchar2( 20),
physics int insert into student values( 1189,'amar',67,39,53,48,51,69);
chellllStry Int, 1 row(s) Inserted
mathematics int,
cqmpurer ..$Cience int insert Into sb.ldent values(lll:2,,'anil',68,34,54,45,53,67);
kannada int 1 row(s) Inserted
english int
); 3) Commai dtoD/splay the descriixion oft he fields in the table usrzg desc cimmmd
desc student;
Tobie created a< ~:tJ-ft Ti
fill~ 51! m:mt:~r G ✓
~ Var,~ l'1 ✓
2)Commaidtoadd 10rerords i11tothetable ........ill tl•."'lt:~ C ✓
1Sert into S!l.JP.lt v-,,uc~( 11 d,'lcrishna',67,~5,54,53,65,h7l· ~~....! ,: rate: ✓
le -,.- ✓
row(s) trr ~r.I'< ·"'
,..,
- !.ll"".B ~'""- u ~ ✓
f:L&: l•~r ✓

nse1 r in t • e
~ ~•·- ✓

• row(s) inserted 4) command to alterthetabletocalculaleta:aland pe!'centagemarlts.


alter table student add( total int, percentage number( 4.2),result varcbar2(10));
Insert into student values(1146,'Vittala',67,15,45,35,65,67); Table altered
1 row(s) inserted

SJ Commmaod tocaJculateta:almarks.
insert Into student values( 1134,'Hari', 99, 98, 99, 97, 91, 90); update srudent set total= physics+ chemistry+ mathematics• computer ..,science+ kannada + engllsh
1 row(s) Inserted 10 row(s) updated
lat p cnt111e

lntal/6.0,

7J Ct11nm uf lo cr,mputcr th c rcsu It as 'pass' by checking lfth


1124
1125 -- -
Ram

mm1c In CJlh .sublc<.'t. c st udcnt has scored 35 and moreU1an 35


.- 1146
1134
Vittala ... ,._ .....
__._._._.,,
Hari
upd 111 tu I nr t re ult 'pas!:' where phystcs>=35 and chcrnistr >- ,
computer ,Jiclcncc.>•3!; and cnglish>= 3 S and k:annada>= S Y - 3 Sand rnathernaucs>=35 and 1128 Murali
3
5 r ow(~J updao.:d
1·1 02 harish ~
1104 m!_hesh · ·
1114 abhay

8} Gomm a
nd
lo computer theresul as 'fall' by checking lfthestudmtbas scored less than 35 marlcs In
any oncsuhjc<.1.

update student set rcsult='fall' where physlcs<35 or chemistry<35 or rnathernatks<35 or


1189
1112
emar
anit l
12) commaidto fist the students who have resut as 'pass'
computer ..sclencc<35 or english<35 or kannada<35
5 row(s) updated
select• from student where result;=' pass';

9) Command to list tJ1e contents oftable 1)12(


I ~na 11 $ :4
~~
Select • from student
111~Rim 35 (~ (~ 5) m
-·--~~----- ~-
--
g
---- --- --;i- --!i!-- .

10} command to retrieve alltherecord ofth etable


select • from student
U.J.\
-~- -
Hi/!
/!el mf.s,1 !Z
~ ~

!]
~

~
- 71
...z......_ _ _ _ _ _
5'
il
--
i~
--
!;,!
~El
[]
--- -
~

: ll!i . al',. 61 13 ~ ~
;-
H m :1: fa

I
I 11)~ R3ll 'r
t, .,

-~ •'
;, [j r; 33:' :6,5 im 13) commaidto fist the students w/10 have resut as 'fall'
'1!6 Ve.', 61 .,, ..'• aa .cl~ct · irt•Mstudent where result='fail'

1131 Hai
.
:.. ~s f'

113 l'L'ra\ fl !- . '··


1101 t.r.sh 83 J [,,
,.
~~
,, 35 :A 13
"!)j ;r,1he;h $ '1 ~l ;:J) r,~ -· - -- .,- ,
- -
a
--
,\fl? n;rsr. ll ~~ iJ f7 :12 .
.,,,
89
!W a:hl1 il ,,1• Gl ii
p
JI J52 !a!i1 fa(
r!l ___ - ili.., bi

---. --·~- 7~ ...... ...._.._..


24 61 i5 l3 :J Ji2
l 67 l! \J Jl 5i 6~ m !45 ... --.,;....,;,,...;
p21l !~J1 ~

..
.--- -~
!1BJ ~H bi
-·-·-· ,..f~~ ~:..,.-
·\112 -~ ~3 ' l4 ,, 5-1. !5 :J fl 321 ill
llll rl &5 34 54 '5 5l 61, l11 , m fa?

14) commmdtocountthe students who have passed


U)Gommand to retrieve ooly student ID and student name ofaU thestudmts. select count(•) as passecu tu dents from student where result=" pass'
selectsid. sname fromstudent;
ch1•canttr><► My ,cacly
ccmtpchll,l,call,p•r
ct~
<cmtt'r.><form mcth od=" post" acto
/l ntn /1,I n=" ">
<.cl II C
<lJ1l11 stylc ="wr lth:4 50px ">
/lClt lt l /Id > <tr>
0 run /< l'ltll 'r.>< /Id >
0 to 4:(>0 p111 <td> N~mt:- /td,
</ce nter </Id > <td> <mp ut type- "text " n.ime="namc"
i)0 to 8:30 pm srze="20"><,\d>
< /ccn tl'l">< /td >" </tr>
</tr > :00 to 11 :00 pm
< /cc:n ter>< /tcl > <tr>
<td> Class:< /td;,
< /t able> </ce i1tl:' r> <td><select n;imc="dropdown" frl•"c
lass">
</bo dy> <opt bn valu e="l "> 1st PUC </op t on>
</ht ml> -:opti:ln valu c:"2" >2nd PUC </op ton>
-/sel ect.> ~/td>
</tr>
Out put:
<tr>
<td> Date ofbi rth:< /td>
<td> <inp ut type="lext" namc ="do b"
size::="20",,, ft.d>
</tr>
<tr>
My study time table <td> Gend er·< /td>
<td> Fcma le<in put type=o"rado" name
="gc nder " v.iJue="Femall!'>
Male< inpu t typ c= "red i:l" name =• gtnd
Days SobjKts Morning srudy tlmt table er" value::"Malt!'>< ft.d>
College study time Evening study tim, uble </tr>
rtadlng Qumioo paper <tr>
la.hie writing
~fonday Ml:Ilada sohing
5:00 to 6:30 am 8:30 to ~:00 pm <td> F.t.h erna me:< /td>
Tu.>sdo,· English 6:00 to 8:30 pm 9:00 to 11 :00 pm
5:00 to 6:30 am <td>< input type="text" name ="fn .ime"
S:30 10 6:00 pm 6:00 to 8:30 pm size="20">,,, /td>
WM?:esdly Physics 9:00 to 11 :00 pm </tr>
5:00 to 6:30 am 8:30 ro 4:00 pm
Tlnml!ay 6:00 to 8:30 pm 9:00 to 11 :00 pm <tr>
CbMllSIIY 5:00 to 6:30 am S:30 to 4:00 pm 6:00 10 8:30 pm 9:00 to 11:00 pm <td> Moth cr name : </td>
Foday Mathemat:cs 5:00 to 6:30 am S:30 to 4:00 pm 6:00 to 8:30 pm 9:00 ID lJ :00 pm
<td>< 111put typeo="text" name ="m name
Compnter " sr2:ea"ZO"></td>
S!Imtiy </tr>
Sci= 5:00 10 6.30 run 8:30 to 4:00 pm 6:00 to 6:30 pro 9:00 to 11:00 pm <tr>
<td> Co liege add rcss: < /td>
<td><te>-t area rows= "S" co Is= "28 ''><
/text .area>< /td>
</tr>
<tr>
-- - -- - ----- -- -- -- -- -- <td> Cont act num ber: </td>
• • .,.:• 1!1!t> nf. N 1•m bei 22 <ld> <inp ut type= "text " nJ1T1e="01"
sae= "ZS" ></t d>
< / l !">
. Z)lr eate ~tr>
-htm l> <td> E-mail:< /td>
<he • , <tJ ><in pul type= "text " name="em
:111" stze= "ZS" ></td >
</tr >
<scyle>
table , tr; td <tr>
{ <td>
bord er:1 pxso hd black ; <i:Jp ut type ="bu tton" vah.te="Submi
t" name ="su b">
} <inp ut type ="bu tton" vah.te="Reset"
name ="re s">
</sty le> <inp ut type ="bu tton" v.we ="C. mcel
" name ="ca n">
</td >
<;be ad> </tr >
</tab le>
<bod y> </fo rm> </ce nter>
<cen ter> <hl> Stud ent regis trat:k </bo dy>
m form <;11 1></ cente r>
</html>
Student regist1--ation form
--
f lll
- ][I --- - - J I
[u _J~ 1 sl ~UC :..; I I
loato of bu-th - ][
~e1~er: ljFemale O Male 0 I
[Father n~une: I
~other name: I ·-

College address:

!contact number:
IE-mail :
II
I
- :: .J I
i; Submit I~eset ] I Cance~] I

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