er OY
Structure
—_—— et ‘
aiucie 2 7% acollecton af dePterent tata types gmoup
ed together undey a sfngle name called styuskre,
(on :
BM a collectfon of hater geneous data type roupedisme
“to geduey Undey a Single name called, Struchye ,
Symak & '
ne Atagname >
datatype member 4 ¢
datatype member 4 5
datatype member n+
(ow
gaructalagname> Viva V3" YR
ae
PR Struct fan
8
Chay darganre 96):
Pe dling ¢
Ruth speed !
% Si,S95
tor)
Struct dan s1,¢y
porter _potdls ¢
te Shucture fe declared by uafng the Key word fs
SUCH and tog name fe “he name of he chnichure.
& dflferent cata Types members are declared why My
[P
ad.
a Shuche known ae Structure Members.
= |
Scanned with CamScanner3.
a
5:
o, —_
ft Sem
very hucture should be ened w Color
Structure yqaples ave declared atthe end of te
Stuctuye. 7
Shuttuye vartables can be Use -4) access Struckire
Members by using clatr operatoy-
WARP Yo create adem detatle and Print Hem
=e Ynclude a $4afo.h>
Strack chuderr| cletafils
x
oer name [20]?
Fn lino!
Char Branch feo]:
mafnc >
&
Struct stddentdetaris s+
PifoHt Center Your mame'>s
Ny o!
Scand Oy, 6" £1.9ame):
PREC “enter yet number”) ¢
scant cy, 4", A, g's a
PTOI C enter branch haame" 9s
‘scant C765", Sy. wranch)+
PAPC name = hs» Sr-nome)s
PMH voll noe ed 1 Sl volino):
:
prt cs Branch= 6s 81. Branch):
WAP +o entor siudad detofte o4 thyee members.
aE tnclicte aslo >
SHUCH Stedetdlls
2
att
Scanned with CamScanner| Chay name C2q)5 ‘ 7
For avltno s
Chay byanchio);
motine )
» “ " uw 4
Stuct stdletaite g- Fnac, to0,"ece-e ge
6, Ww ae
Shuct Sid dole ¢9 = Sez lol, ‘ece-B be
ct Tle co = OM f
Shuct stl detoile ss « Spor” to PecenBR
erintt Cuame=y.c rolinto=%a branth=%-8", 5s nome,sy adi,
Sg. branth)*,
winkec® =
Nome = "2S vollno = %od bvarith = =%S Sg iNaMr, So Tol nu,
PFO 0° Nore die a 83. branth) 5
No=% 4 byanch=%s", $3.NOM¢, Ss tdhy
4 Ss. branch):
Arrays to_Sh shuctuye .
We can dectave struchuie vaRable ac an arvay «
syntat»
—_—.
Shuct
NA Po enley three Shudaue detatle HEY arrays
“fo Stuctune.
SF Attu dex e1d%. hy
Suet sud ent
=
Chay Name fra);
Foy yoNno +
Char branea pity;
fs:
a >
Prat Sra ey LS ’
srl Studeut sta] = =}3*anc” 100. Jece:B hg “ws: ‘Dh, eee
did iron", 102 ece~e'p}
A FET
Yer C8205 3 Hy
3
PRE Cwame=%o pit sora prandh=6" SY Lnlame,
1 SET. Bronth): =
& r
-
WAP 0 pit cluded name mpl No. Struct sha 2
Ghruct £409 a> ts RS
5 Slow y;
te Bas
ie Fst
"Scanned with CamScannerWar fot
=e Tinclude < Sl Po. hy
euch Name
Rav aS
Sloat 6)
Shuct Name dt $
2
Pat x6
float y+,
Bods:
gS
mont )
3
Saa= los
So.b 10.987
Sa-S).%2 157
SaeSpeyr 26.487
Pint ary”,
Neol cd chucture -
So. a)¢
Print Clb = yp” a
| prins.¢ xe xg? So. Sx)
Piatt yes 2
; nth ye Zt" sa.5.. ye
Competing sin UY? se can not compare “hoo APH erent
struures bub we Can Compare two Afffevent Stvuctuve
variable of came sloyeluve, members
Wa p for Comporfre ghouclures -
=k Prclude < tidfo. h>
StOuC} studen!
2.
char Name (oo;
nt roll no 4
fifa! marks
el
Scanned with CamScannertt
™Mafine )
2
4
Struct ctuden! sre $" pavant 1000 HE 2E FS
Shuct Studer) so= Peanifina ot, 36. 26 Ft
& 98(CS1 .r01IN0 == 85.vollAd) &.£.¢S). marks
ep
EO 6 ane Sg are equal");
Ice
PIMC S, and go ave not equal”;
gy
Péintey -1o Shuctuvee 4 pointer Vaiiavle holas tec.
Fantey “to Srruciuye’s.
edddress of a Structure
cyntar?
shuct
L .
data Sype member ts
V
Septr;
cor)
Struct Ataqnam > Ptr P
“To excess ‘Struct members vee Can ‘Use dor operator
Cov) membey Secifon ‘Operator (>) ,
WA P for pointer “to Shucture-
=bIndude |
AUCH bANk sie PLY 5
: pire £3, ve :
sirepy Cpty—>niame Bunny’)
PAVED Aceno = \23ue7
Pir > balance = lasac.964
PALE nrame=% 6", Py-oneme);
Print c™ mettnoey, a”, pty egtno);
Divot? C balances IP, etry balance):
a
Structure 4p dunctfon e swe cae pass hucture+0 Perey,
-n fn tree ways.
d. Passing individual structure members.
22% fun @ char namevmaccountno « float trabance)
2+ pasng uate sructuve name,
€22 fun C bank acture
3. Passing Si» Addveccec,
€1% Pun C per).
WAP using Shucture 0 dunn,
HIndlude cet flo. hy 1
Shuck book |
2
Char booknamte]:
Char authoy (202: |
Pop Pages |
—> Hloat price +
b
76d d@splay Estruc book) ’
motnC >
2
hg ; .
ome book bk = D pps’, cer as 39-2535
splaycox)/
—
is ll
Scanned with CamScannervoid display Cohuct book bk)
print? (\Bookname =%0' 4 bk. bookname)
printf Cc“ autnore% 2", bk, author)3
primer Pages = aa", bk. pages) =
Pinte’ pfce = x4", be, Pree)?
%
Scanned with CamScannerPe a |
UNION
unfong The Comb?nalfon of different clataypes qroupey
Hogethey unter A ingle name called urfon.
swe keyword fy union Fe “union! .
lax 2
Unfon
3
daratype memy +,
‘
. tor)
orion ~agname evar yf --
WA PO PAA! Bop Name aittor , pages pice cing
urfon,
ar indude
urffon book
S
Char boookname (20)!
Chay author (20) 2
Int pages +
lost pritee +
1
Struct books
2
char bookname 20):
Char author T90)*
Sint Pages $
float Prices
he
McRin¢ y
urfon book bit
Struct book S17
Pre OG coh etyucluve era bytes’, Reeof.cs.0)’,
PHO Crea Union fo Ma. bytes’, Paeoklbr 7):
$
Scanned with CamScanneray ptterenct bekweer ‘alyucluve and unfon.
fe
A
fh rr
__ 1
shruclure
Gowe The Key Word used -fov
ermucluye fs chruct -
om
2. Each members In shucture
allocates T9 Seperate memory,
%. The sige ofthe structuve %o
+eSUM of all the members!
Fn we Stucture-
A, Shucluye occupfes More
smemory SPC
symat -for Structure fs
struct Ltaqgnamey>
2
datatype memd ’,
,
umon
Hf othe key wore Used -foy
unvon 7s urfion.
Q. all membere9n urfon’ uditt
share Coramon Memory
cthat?s heghes! memory.
2. the Size of the urfon %
she Largesi member fra
unvon. . ‘
#1. onfon: occupier lecc memory
Space
symat for airfon %3
orton 4tag name? «
3
dala type mem 4,
1
i x Vayg e+ %
Ward + 5
Enumarateng enumeraifon & used dorsymboife conston)
—t seta values .we Use the “key word Feynenumeraten n
toumaratfon the Steak hng fever ator? Wir . and ca
vin (ny, t
symay, yet
‘eoum etagname> I mem 4, vmem2’> ~ >" * ub
ext F
= ,
MUM werk SS ron’, que’, st sun by
Wap using enumeyalfon. ‘
aft Include <. Std PO oh >
enum aye J mon! . Stuce’ Peden, “ipure’, fo?” "sat, “sun’d >
mahney
£
Scanned with CamScannerenum dayo Stat, ends
Stan = tues?
end = eae
OR iid C ghar = tod’ StOVHDS
PBal C’ end=%a", ends
2
Typedef £ °c’ supports a new feature Known as
maypedetfretfoen, MH allows the useY so wleuttfy anew +
data type -bran exefering tata ctype +
symane
| aype def datatype SDENTIFIER
€12 typed? Fat MARKS! . .
trom-the above etample the \demt?tPer cot) new data
“ype should be Witten '?n eaphyah’ teitey -
I AP Using, type det: '
Aindude atdfo.h>
mint)
sypedef 9rt MARKS 5 ' y
MARKS Mmyme,ms*,
pint (enter 2 subject marks’)+
sean? O'Y.d%d%od", Lmidm, ms)"
PAE C epcseplya", Malas,
bipflelde Ltttea tn ‘d spe cttee she Cire of, ets
for Siructuye Cos) Gon members. Whe ea fe uced te
use “tire memory eH?cfentty. .
Symtan
unsigned datatype 4
—
Scanned with CamScanneraia Using be-field .
at Pnclude 2cld?o hs
awct dale
2
ungtyned Fotas
Unsigned Prt m 4
unsigned’ Ferhy s
Bs
matnc?
8 oat Cmestze of data Fs vrei", S9eof CSPructeate )) +
ehuct date at = $23. M+ 20199
pint (pate Poe bdvedrd | dt-4 y dtm, At. ¥),
coumena ithe arguments 2 tHe arqumenle Can be pasted fn
a mafnoduncion ge Known, as Command ffne arqumeuts ,
we Can Cont! the prvqyann exe -from ouddte Inread of
changing the Code ab brn qramme.
Symiarg
mon Cnt arge - Irragqvl’ I)
5. \
$ 5 A argv
ane Zgraurnedd pass “an
tere arge velersr 40
reefers to tne Pointer that
Wap ustag commend Ene cerqumendte ,
=e Pncude 2tdfo.hs
mein (fy arge » Charaeavg vEry)
‘Ularge = =27
Paate Co The aijument f Baraat Bra 7
se P Carges2) ing testfng as, arqueD)s
paste an ary
2
Prine
? TENE Cog many argumentey¢
else
Scanned with CamScannerPfirtt Cone avgument % expected "ys
$
3
Scanned with CamScanner