Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
46 views23 pages

SQL, K - Map, C++

The document outlines the definition and implementation of various classes in programming, specifically focusing on student and square classes, along with their member functions for input and output. It also includes SQL commands for creating and manipulating student records in a database, such as inserting values, calculating totals, and finding maximum and minimum marks. Additionally, it discusses Boolean functions and their simplification using Karnaugh maps.

Uploaded by

Pankaj Saroj
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)
46 views23 pages

SQL, K - Map, C++

The document outlines the definition and implementation of various classes in programming, specifically focusing on student and square classes, along with their member functions for input and output. It also includes SQL commands for creating and manipulating student records in a database, such as inserting values, calculating totals, and finding maximum and minimum marks. Additionally, it discusses Boolean functions and their simplification using Karnaugh maps.

Uploaded by

Pankaj Saroj
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/ 23

CIASS^ALe

Date
Page

Bocleau function FCA, B,C/D)7 2(2,3, ts


425 CRveu th,
oduce t usiuo k- ap
&uadi
A6 CD
pair

AB .Tinal SoP epressiou is


AB
13|
F(A,B, C, D)= Bct Atr
AB

Defiue a class naroed student oith follooiue


435
cortesia
membass: Sublmasks, sub2maaks oud
i. Dota
total marks
totalc) display)
it Membor tunctio us: nputc) aud
tie cass -to nput
t Deftne member tunctorn Octside
display Sub]-roarks, sub)maaks.aud total
Cuuc
marks of studet
#uctudetostrearo bs
Sols clasc studet
totalhoarks;
paîvate: int subi-marks,sub2_asks,
public void înput;
voc totalc);
ved displayc);
votd studeut i: inputl)
Cout Euter subjecBi msaaks
cins> Subl aks
Euter
Cout<zSuter subjecta masks:
cins> s ub2-arks.

VOid studect :: totalc)

total masks subl_aoks t subl ngaoks;


clASSmAte
Date
Page

v&d stude ut. display)


Co ut<< Subject1 oasks
coutKe ?s<sublhoaaks
Subject2 mazks is< sub2-oaaks
cout<<total oasks of tuo0Subjecte is <totolo
uoid ain)

studet s;
s.fnputt);
ctotall);
sksplay);

4t Ustug iueu saL table uoite tho appropriate S8Lquusy


Res No Name DOB Mosks .
-Prakash IS-06-2000

1002 Kamal -08- 2000 330

j603 ktt As- lo-2000 4as


is To develop tee table ofth aboue fields
ü) To fud total hunober of students
ü) To fnd the sbest roasks.
iv) To findtho looest marks
V) To display aue studersts irfosnoation
i)>create table student (
Peo No nuabea c4),
Name Varchar2(ib),
Do B date,
Mazks number(4)

’înseart Roto studerot vatues(ioon, Prakash, 'is-06-2o6,525)


’inseot oto studaot valuss ( 1oo2, Karmal 24-08-9co0', 3),
’inset rto studeut values toD3 Qs-to- 2000

425);
cAssMate
Date

Page

student
Ref-No) fro
Select courst (
Marks) from
select max( Marks) studerst :
studert
iv) select nin (Marks) fror

V) select * fro studerst:

Grueu tu Booleau function FCA, B,CD)= Z3,8A,


tt ust uo
lo,l, (2, 14), Reuce k-map
AB CD

AB
Auadi= AD
4
uad2= BD
AB 1 13 : i a l sOP epres'by
AB

a Deftu a class named squarewitt foloeiu criteis


OL. Dota membs: side
b. Member functious: oputt) aud outputt )
c. Deftue merobex tunctions to input tea dota volue
aud output Squaae
Note fomula to calcul ate arsea of square a Sidet Side

Solu: #include<iostreanohy
class squa re
paivate : oat stde!
public : void înpute);
void outpatt))
Data
Page

cquane Tnput)
Cout<Eute tho sfde "
cánss sfde

vÑîd Squate ,? oput( )


tlocct
sfde # side ;
cot<< rea of a squase ="<<ara"

void noaint):

squaze S
S. ioputt;
S. output)»

#includefastrearo"y
class square voi roainc)

pri vate : double side: squaye s;


publtc : void ing s-inputU;
S"outputel;
Coutke Eutex tle side ".
cins> side:
3
Vvoid out put)
double area
aYea cide * side
Cout r? aYea ofa sq ceate DLaea
outptc), void
cins>b:
th. bread Euter coutce
3 eugth EutesCout<<c
putO} a. input)
outut); void
toput()i void publie:
int
b:l,private:
leuoth class Solu
am.bs <iostze include 4
b au forl Values output aud
toclass toutside
u functions merobex Define c
Outputt) ioputt), tunctio
:us Mengber
baud :Lneobes Derla a)
esia llooiog footh axea class Defiuo
a
epressiou Sop fiucl The
is
paivt
|14|
wX
wx
Quadt=
wx
k-map ustue
z)=2(2,t FCw,,y, Reduce
41 2, (0,
13, 5,6,%9,
Page
assmate Date
clAsSMAte
Date
Page

atoite te appropiate saL qtry fox tha tottouoto:


Reono Name subimaks
2005 kKKK
subemaaksTotal
2002 6 49
Q001 SSS 5
(a) Create a table 'mak} oitk the abouo. fields.
c Update "Total' oitt -tio suro of subtraoks and
sub2masks.
Tind the bighest marks n (Total
(d Soot te table on coeono' field.
1e)iew all ecobds

cveate table ocaks (


Deano numbeo (4),
Name varchar| (o);
sublarks nuobes(3),
sub2maaks numbere)

ioseortoto oarks values( 2005, kkkk,98,95);


inset oto masks values( 2002 GGc', 46,99);
inset into masks values( Jo01, 80);

(b) update marks 'set Total = sublmarks t subroas ks;

() select max (Total) from matks;

(d) select t from masks ovdes by oeono;


(e) Select * from maaks
classate
Date

Pge

35 Woite sBL Commands to peartosm tho fotlouoino


ETD ENAME EDEPT SALAPY EAGE

a) To Cxeate tleo aboue tabie


b) Tnsebt one ecod
cs Add a new colurmn EADDRESS
dy Delete employes wbo reached -tao aÙu ot 60 years
e) Disçlay a ist of eenployecs whose salary is sooo

a) Ceate table eMp (


ETD van char (4),
ENAME varchar2(6),
EDEPT Varchar2l io)
SALARy Number (6),
Number(3)
insest into EMP values hlorxY2'. Acao unt!
(b)
65000 35);

() Altex table EMP adJ ( EADDRESS vaxchar 2(20))

Ld) Delete fro EMP esbere ecne s= Go;

(e) select * tom EMP.-obere Salary = 5000j

Ciuau ttu Boolean function FCA, BLC, D)=(o,2,6, 1,8,9,


to1, 12) Peduce t using k-ap
AB CD Suad = BD
Quad2 = AB
AB AD

AB pir2 = ABC

{inal Sop enpregsiou s FA, B,c D) = BD t AB+D+


ABe
classmste
Date
Page

th follooino
Define' a class naroed suo
Data nembers : X andy
condriong
îrput aud outputc) imc
19 Mernber functions : frpud)
) Defineoembey tunctons outside tho class to
cud output
Sol4
+include <fostream-hy
dlass Su

public : vid inpate);


void outputt);
void Sum 1: nputt)
Coutc< Entes x valuo

Couteertes y values

Sum : outputt)
Coutc« The alue of Xi s X :
cout<< The value of yi s < y!

Void mainc )

s. ioput
S" octputt):
classnate
Date
Page

3> Ustuo iveu SoL table vooite the


appropriate sOL
quuoy
Reo. No Name DoB Maaks'
4000 MMMM Is- 0G - 200 SO)
40002 NNNN 2l4-644-2002 325
40003
10-04-2004
To deualop tea table toth abouo fiotds
u)To find total nuober of students
To fiod bishest masks
To find louoest masks
v) To display ll studet's îoformotioo
3) cTeate table studeot
(Ref.No nuober (5),
Name
Vaxchor2l5),
DOB
Marks
date,
numbes 4)

îosert ioto studeot values 40001,(MMMM'


IS-06- 2008, So1):
osest ioto studert values (( 40002 NAN'
^24-420o8 325):
inseot oto studert values ( 40003, yyyy'
lo-04- a00g, 4to);

R) select court( Narne) troro studert

i) select roax ( Masks) fom studest;

iu) select minl Maoks) fom student

) Select foom student


classHate
(IO, Date
Page

LL I3,
sReduce FCA, B,C_D) = EC0, 3, 5, 6, +
8,
usiuo karnauch map
CD octete : D
Quadt : B
AB 4L s
guad2: BC

Tha fiua Sop


ezpreo
12
AB
wis
FCA, B,C,D) z Dt BC+ Be

Give SSL coroands to coeote STUDENT table


oth the totlosio colunmos. Find the total average
aud display total, aurafe foo each studet.
Rento Nanoe Sub-1 Sub-2 sub-3Total fuerabg

Solu '- Create table sTUDENT:


nurobertE),
Name Vaschas(0),
Subs numbtxt3),
sub-2
nunbesl),
Sub -3 humbol3)

insest irto sTUDENT Values (tooAAA 4, q0. 48);


psest Roto sUDENT Values ( Lo02BB8, 9,98, 3)
nset ioto sTUDENT Values (1o03,RRR', 94, 85,109

Hlter table STUDENT add totol Dumbe3)


Aerabe oumb(6,a));
’update STUDENT Sub3
Set toto Sub-1+ Sub- 2+

’ update STUDENT set Aurase = total|30


classmate
Date

Page

select total, Auera5e from STUDENT;

Boo leau functiors F(,B, CD) = co, I,2, 3,4,


12 1a ). Reduce t by usine kaauah nap
cD auadt= AB
AB

ÀB D
AB paiz
14
AB
AB

iual SoP epress iou is FCO,B, c,D)=AB+CDtABE

class t i e uorth foltowio mebes and


Define
Con ditious
seconds
Data roersbeos : bous, rooute,
funtions : getdata aud disptaye
) Mernber classto ioput
i) Define menober tutions inside the
secobds
Qud output bour, îpte aud
# ipclude<iastreamb>
class tinne

potvate Rot hourr, nointe, secords;


votd atdatac )
public
Coutte bour
cinyhous
Cout<erotes inute .

cout <t Entea SecOnds ),


cins>secouds"
Dote

( Paqe

void displaye)
K'Miotea' roinute
"Houx"zhou
coutc< 2<< seconds << erd;

3
3; maiul )

4Rme t;
tgetdatoa);
t.displayt0;

Usiuo iuen S9L table nt te the approPoite sL


quy tor the olosfus Masks ) To cRte th
Student_id Name
ABCD table. eotth aboue
1002
60 felds
Solu) Coeate table studert
( studeut d DumbesA),
Name varchar25),
Masks nusbeol3)

To insezt too oe cosdsoto the table.


anseot ioto studet values (1o0, ABCD',80);
insest ioto studert valuis ( too2,'utxY2', bo);
ko To ftud the hióhest marks.
select maxç Masks) from student;

i)To fud tl total numbes of recods.


Select eourt (NlaMe) from Stude it:
classute
(3 DaBe

Page

V)
To Qist ale tee ecoads of tho tabe.
select * from Studerst;

GtuEu le Boo lean unction FCAB,C,D)= SCo. I, 2,


3.4,S,6, 4, 8,4. IS ). Reduce t usfng k-map.
cD

C CD Octete:
AB D 2
G
qaad;
AB 12 I4
The fiua Sop epresstoy
is fCA, B, c,D) = t+ BC t BcD

Define oa class. naroed triaugle uortb foltocoin


Csiteia
Datoa roerobos base,betobt
i Mernber functions : opudtc) and out pute)
) Define oerober functioos outside tho class to îoput
Cud ouctput base aud heigtt of a taiausle
Sol fnclude <tostiearp-b
class tiausle

private : iot bese, hisht;


public i voi d înputr),
vo?d otput ),
3;
votd tviausle :: iput):
Cotr< Euter base duud hei6 t
cçnss base ss heigt:

boîd troiangle :otput)


cout k< Base ="z<base '
elassnate
Date
Page

coutk< "Heis bt <betsht;

maint )

toiauole t;
t. ioputc) ;
t.oudput;

O Gtue tee Booleau functon FCA, B,cD)=XU,3,S, 4 29


lo, LL, I2,3, 14, 1S) seduce t usino k-ap

CD
Octetee: D.
A

AB ,Final soP expressioy


AB s
FCAB, C,D) = DtA

Arth gefaveuce to te table Gtuu bos, oîte te


S^L comnauds to pesform te -follouoin optratins.
Table Alame aoplayee
EMPID CANE DOB
Salavy Net Salaty
28-01-12 500 00 49000
1002 EFG 29-0s-O 6000 D 4so00
l003 (4-0L73 4S,oo0 34po0
PaR l4-63-44 44000 340 00

a) Cate te table efth abou ields


b tnd the total nurobes of enployees.
odte minimuro of Net Salay
Dlete ale -te ecods foom te table "ermployee
e) Disp lay all ehployee ecords ohose Net sulaoy ts
6reates than 4oo0
classmate
Date
Page

n) Coeate table eoploy ee (


EMPID
numbeaC4),
Name yes cha2(io),
DOB doete
Salaoy number (6),
Tax
numbol6),
NetSalay numbert6)
D;
Rosert oto employee Volues ( loo, ABc,'28-01-2,
s0000, 10000, 40900):
nsest toto employee values(4002,'EF4''2-os
GO000, SO00, Asooo);
oseat to eoployee values( lo03,'x\z', Lq-04 -73,
4SO00, g000, 36000 ): .
nset Goto eroployee alues(too4, PSR l4-03- 744
44000, oOÖ, 3400);
b) select couetlName) from eployee;
C select oin CNet Salary) from eroployec;
d) Delete from employee j
e) Select foom enoployee whee Netsalary s4000o;

O Guou tle Booleau functior FCA,B,CD) ECo, t, 2,3, 4


6.8, lo, 2, 13, t44, lS). Reduce t usius k-mup
D
CD CD D.
octte: D
AB 4 quadt: AB.
AB Di
AB .fuel soP epsSios is
ECA,BcD) D+AG+ AB
clAssMate
Date
Page

DSi no tueu SSL, tble oitt tu appropriate s9L


PesNo Name S S3 S4
SOot XXX 40 30 45
55
35,
50
fields
a) To deualop tte toble uitt aboue
coluhor tota
b To Modify to table to add a hew
6 Cornpute total.
d. To find totol nuobo of studénts
To display ao stude ot rfoation
Sol" ay Cheate table stud
(Refrlo nnbr(4),
Name vajchar2lto),
nmber (3),
S Dumbs 3),
numbeL3),
Sl numbe3)
J;
Luset oto stud valuus 500, Xx* 60,40,30,45;
nsert oto stud values soo, yYYS0, 3s, 60, 55);
h ter table stud add( totol embir(3)):

c Update stud set total = st S2ts3+ S4;

ds Select court(Name) foom stud


ey Select from stud:
clasSMate
Date
Page

CRueu ttu Boo leau tunction F(A.B,c.D)


4,8, l0 U, 12) Reduce it siuo k- =(o,2,3,
-ap
AB
CD CD CD

octete: B
4 Suad: CD
2 1s fiual SoP expr is

Defiue cL class Accounts toith follooino membess


aud cordtious
Data noembers accHo, Dame

Membeo functions : înputo aud utpat)


ioput
tü Define membes functious Oudside te class to
CLCcnO Cud
Cud output
incCude tostrcagb
Solu
clais Accoubts

ot CCDO
char Dame EtoJ:

public: uofd ipputt0;


voîd outputt;

void Accouts ::inputj


cout<Euter Acot numbs1Do

ins acchO"

cins ncme
classmate
Date
Page

Uoid fAccouuts
buts :: cutput)
Cout < Accouut nuober îs 2
<accno,

void meiinc)

Accounts ;
A.inptc
A- outptJ;

3 alofte ta seL qusy foo-tha follooing quastions


based on Siueu EBut table
Name Units Bltdate
lol AA 135
rnlo2(2002
to2 BRB
Cc
228
J30
Islo22002
I4 022002
iy Deue lop -tae table' uith aboue fields
) Display tle stuctuge ofte table
fud total nuobes af recods EL
0)Fiud ttee Sum of cll units. consumed
v) Tisplay ale reCoxds of Ebilt

Crecte table Ebil


(Rmumbar nupberc4),
Name
Uits
Varchorel5),
BtLtdate numbes3),
date

nseat irsto Ebi IL values (lo,'AAe', 3s 2/o2120D2)


tosest into tbiu aluer((i02-, 102, BBB, 3g,
S9g, Isle2(2002');,
insegt Eoto Ebiit valus( lo3, ccc', (80, l4
/o2(2002
cdassate
Date
Page

dose Ebltl;

selec .couut( NanMe)from Ebiu;

)
&olect Sun(Uhits) fsom Ebítu;
fnom Ebitu;

Giubu te Boolea function FA,B,C,D) =TCO, 1,2,


3,4,6, 89, to, i) Redue t using k-toap
CO
octete ; B
AB
A

AB +2

The fiual soP expressiou is


FCA,B,e, D) = Bt ADt Ac

fo[towino merobes
Czeccte a class stdet aud defne
functious otide the class
) Dcda roember; e ono, narpe
tc) Membr fuoctions : etdeetac) aud displayc

Soln: include <iostream-b


class student

Rot agono,
poivate chas name [20] ;
void oetdatal);
vo?d displayc;
clAssMate
(20 Date
Page

void Studeut:: ostdatal)

Cout<<e Ecte eoista number of stdeut,

cinsseono;
Cout< Eute namo of tio stede t
iuss name

veid studeut ; displaut)

Cout<" ReouoTeono

veid

Studet s;

s displayi

hlote te oeppropriate seL qury fos te fotousiug


quectious based eu giusu enoployee table
enmpid sadasy
30 30,00O
Stoo 38
Stoo3 Ccc

To deuelop tte -table eoith abouo felds.


To fiud total numbes of eoployees
i) To fiud hiouest salasy
S

iu) To fid tte Sum ofot edu


c enployee's salary
To display áll eoployee gecosds ut
ases 30.
clAssHste
Data
Page

cseate table eroployee


( eopid Varchancs),
name Varc har2(io),

numberl3),
salauy nunbev(5)
snsest oto ernployee vobues(St001','49A 30,
30000);
Bpseot into employee valus( 'stoo2', tos, 38,
4soo0);
snseet forto enoplayee values ('stoo 3'} ccc' as

E) select cout Coame) from employee;

w) select max(salasy) froro eployee;

tu) select Suo( salary) fooro eoployee;


v) se lect * foom employee ohese aes=30;
(o,,2, 3, 5
GturM tte Booleau fuxctiou FCA, B,CD)
usiuo k-map.
8,4, to, L t3), Peduce it

CD Co
oetete:
1
uad; CD
AB 4|
2
AB

Tte fiual sop expressiou is


FCA, B, CD) B+ CD
classate
Date
Page

Jsiue gtueu seL table of electaicity bill, site te


Cppropoite saL qwy Aoount
ReNuob Name BELldate
ROOO FFEF Of-o- 2024
Roo02 Ol4-09-2024 300 2100

Roo03 HHHH of-o--2024 260

To develop tte table ott abouo felds


To display -tle staaclure of a table
To fid toto) oumbes of customexs
iu) To fiud tte total ts consurped by ll teo Custoroe
) To display ll custorers Tecosds.
Solu: ) Create table electoicity_bilt
PRNumbr varchasnl5),
Name
varchar 205),
BiUdate date
Units numbesc3),
Amout Dumbe (4)

insest îrto electeictty- bill vales ( eRoo01, fEFE!


os-o-2024, t0, 40);
inseat rto electiity- Bil veluas ('Rooo', GGGq
O4-08-202 4, 300, OO):
ioset into electicity bill valuos('ROO03 HHHH?
os-08-202 4p, Q60, Ig 20):

desc etediciky. bile:


à) select couut (Name)frorm electoiity_bile;
iv)select surm(Units) fos lectitybilu;
v) select from electotcitybile
clAssMate
Date
6 Pace

woite tue
Usiuo tueu SeL table of electaicity bil,
Cppopsicte s8L quo34 Uots Arnount.
ReNumbo Name BELdte
ROoO FFFF O o-20 24
300 200
RooD2 O4-o9-2024
ROo03 HHHH of-o2-2024 260

To deuelop tee table wftt aboue fields


To display -tee slauclue of a table
) To fid totc oumbes of customess
iu) To fiud the total uuts consumed by all tu Custoroer
display ll customers recosds.

Solu: ) Create table electoicity_bL


( RRNunbr vanchans),
Name varchar 2c5),
Budate date
Units numbesC3),
Amowt numbes (4)

inseat ito electoicity bill values ( RODO1, TFFE!


os-09-2024,20, l440);
?nseat rto electaicity-bi values ( 'Roo02,GGGc
o4-08- 202 4t 300,2o);
insert into
electricity-b0 valos('ROO03 'HHHH?
os-08 -2024t, QG0, ig 20):

dosc electoicitybil:
select Count (Mame) fro electriüty_bill;
iv) selact sun(Units) fvoros electaittybiu;
) select frsom electtitybile;

You might also like