0% found this document useful (0 votes)
8 views17 pages

New Doc 04-11-2023 15.30

Module 5 covers the concept of structures in programming, including how to declare and use them to store various data types. It explains the syntax for defining structures, accessing their members, and using them with functions and pointers. Additionally, it introduces enumerated data types and provides examples of their implementation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
8 views17 pages

New Doc 04-11-2023 15.30

Module 5 covers the concept of structures in programming, including how to declare and use them to store various data types. It explains the syntax for defining structures, accessing their members, and using them with functions and pointers. Additionally, it introduces enumerated data types and provides examples of their implementation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 17
Module 5 Introducthey ~ A etvicture Te a usea-ad ved § dato pe See cen ee ele nybarnatten eg a + The vasiables withtn a Stuckure are a Orient date kypes Structure declaration eA ehruckiye ts declared 4 the + bepeons ehruice jotiowsd by the strnuchure - ML the vastetbles ef the etructuve are dechard within the etricture. g ex: Chruct = ébyuck — name. coun etudent 4 oc dota tye e = i} chow nameday char course [20]; Root Fees » etructure. Lrckure, declaration does not altecate @ scanned with OKEN Scanner Sas vs allocated tee tne stricbure when a dechare a Vasrtable b the etwuchure . fee [) ome move structure Aeclarocthony © Structure +> clove cistomer Meamnakten rick = customer ‘ . {ok cust_id 5 dnaa rome (zeJ; cher adders [20 5 leng tot phone nem s int Dob) \g @ scanned with OKEN Scanner © @ Sructuve to ctove Pnpeamation | a. book. gtruck | BOOK § : char ttle [20]; thor author [20], tnt pages; oat prices int gra a Puticont ton 4 © Structure ko store Mnfoumadton of ote Clruck date L tat day, Sak ment; int yor? 3; ® structure tp create an Pnventory veeoad . strut Inventory chow prod aname ( 20); oak pres; Int tout; b @ scanned with OKEN Scanner “Typedet declarabtors * The typeset beyond enables the pregrenunst t create a nae data tyre noms jrom on enisting dota type . + by wang typety ne fee data ye created, aathr an alternate Meme te gen tnewn data e. ee ee [ares courting dota tape new ania | Ex" Lay re . dnitteliz ma ao ehnuickire Trea oxshannng gome constants to tne members dhe stricture , . By Aefoust int, eee ave. Witalized to eee character and sti are tnittobized to ‘\o. ethe Tritlabizers ore endoced to braces and ave Seporated *4 commas . @ scanned with OKEN Scanner 7 ntox Struck ¢truck Lname t : dake pe membea—namet 5 dota type member _ Named 5 datatype member - name? 5 | struck vor = { constant i, constant? , constant 3, 2.6: uy a Struct Student int w no} char name (2°J} cho course [20]; Boar fees; . "es a Fetuds = fot,“ Rahul, Bea’, 4 ty OR a ehruck thudent gtudt. = (0 te “Rahul”, “BCA’ asove | ; @ scanned with OKEN Scanner oo the members “4 a stmichue © A. chuctuve vantable te qersatly aceexed od a cc) dot Operator . Syntax | ==. ¥ Fo axeran weblue to the. Individual data memb errs 4 the ghricture variable studs , we tea wile Studia .wino= O15 eludt. name = * Rahul’ y a ae eluds. Counse = “BCA ; studs \ et Cae ceane (“ 7d", & stud t rene); —_— pant (" aoe ehud 2. course); @ scanned with OKEN Scanner Ex 4 we have two etructure varrables etudt and etude Denon “) Then +o astign ene anether we will write, Fina the fie a Structure (0) ehuck Employer (-Stmple Adlai tien’) : tat om p — ID; chars Nene [2°]; ; double galary, ; char chet nates [eos Steak erp sence 5 7 . Now, Size = gine of emp-2P + sire | solamy + size =) dest < nome t Shr + re OL smpenenes ves on owe ea tron TE FP oe pote t OTF = St bytes |) @ scanned with OKEN Scanner Outing. steel epaaton dhinelude 2stdio h> typed struct Emplo ee mes 4 int emp — 2D ; chay Name fL20]; daeuble sata L char dest (o°J; Peat encpentence 5 y word mond) struct E& loyee e} printh (« zd") sizeof(e)), y ‘ D ole. 54 bytes - ctctures ond Funetters- +h functien acces the members of ehricture 10 3 watts £ nat a Passing. Tmnembors Paserrng strackures Feasting the A | = etrckuve 4o functions 7 the addres Pose “td the structure. * @ scanned with OKEN Scanner . : Lo ‘5 Mass tv Lr Cc) — es o Use the divvet Selection operator +o aha tro the wadividual members . abinclude Zakdlo h> pects} greet int ®5 Mt N53 & points vota display Cint , tot), int matnt) : PONT p& = <2 oF dreplag Cpa > pry); veturn 0} 4 vota atsplay a. b). pant£(* the cooadinotes of the pomt ove! " na ha poe o — The cooadmokes * tre point are! 2 *) @ scanned with OKEN Scanner @ fase Entive. Struchiuve We can pos an entire Urient are Wi as) nets cide hey are sepa te appl shot inves mutt ple members » where vwelttet need not be ouetgned to all members at- ate one time. » Luntax unten ownten- dota type var—name datatype vers name) (Pectaratier) : name 43 Access a member ea unten } the unten +) operator sey « Vee the (dot) Pp ihe dot °P : @ scanned with OKEN Scanner i) intelieng untens oA tater Aterence , between a astriecbure and a unten te that 10 a oe the elds chave the game i hesteleaita epace, So fresh aot replaces ot og dotn, m Br ineturde eetdio h> Eyrede} struct = POINTAL 4 int xD uy “ypedey unten POINT? t int x} int Y5 3 Int maint) 1 pointa Pa = £2.34) point2 P2d } pre 4} prryeS; proty(® the co-oadmaker of pt ave yd Vivid) Pix, Prey). pant) (© the co-oadmates po ave yd & sd’, P2e% » PRY)» vetuan 0 5 @ scanned with OKEN Scanner Unienss ond tae eon be ung wa when gnetde a etructirre. ae ' + The fotterstng, code 4h inctude Zakdioh> etruct student 4 unten i Aechares) jltustraber Sueh scenario. char name [2°I; Ink AGU-NO 4 tnt mares d 4S got maint) t gtruck ekudent stud 3 chor choice; pontt (* Enter name & painek Co De you want te Enter nome 2 ey or N)s ”); gol no : 7 gets 6 choice), iE (choice eaty’ I ote yD pant Ce Enter tre nome"); gets C stud nome); 3 else, @ scanned with OKEN Scanner , ) prints Ce Enter aclt no); geant Crxfpd", & stud. woll-n0); 4 ’ panthCs Enter the mares"), seank ( fd", & stud. mourles J; iF Cchoree = = ty? [| choice Be) pratt (“Nome: fo", stud. name). else : ; printé (“Roti no: 4d, atud. roll-no); pant (Masti: fd "Stud. raves); vetun 0} @ scanned with OKEN Scanner Enumeratied |, e The enumerotted data ee «(te type bared en -the clandord Coes + An Enumeration - const i eu Ss) wt Integer constants - + Dn an enumerated Peo Each Se Cae Ye asstaned an ee . te deine erummenatad asta types, woe ise dhe eyworad ent - + Syntax! * enumeration name { tdentt pier > 2 paerssgths yoy eased Evarnple. enum covors {RED , BIDE, BLACK, GREEN , YELLOW 5 puree , WHITE do not asttan nt eS ad e In Caste ye Ane be conttunt , sire. apes wale jh ' ys oO. ee undepines constants ewe @ scanned with OKEN Scanner The Bw. code Tllustrates the Dee and access of erntemerated — dacta kypet at metude <8! ioch> fat maint) £ enun GREENS F ,TELOW , RED= 2 , BLUE, BLACH=5, purPLe , WHITE ie pantt («RED = a print (C* ewes 4d", Bive); pantt (* piace = 7d", BLACH); paintf ( «Green 4d", GREEN): panttce« velow = /d", yeuow); pantt (« purple = Ad", PURPLE); prott Cs wHitE = Zd", winire) ; yebun 0; z tp RED= 2 Bive=3 BiAce = 5 GREEN = + YELLOW = & purPle = 4 wire =15 | @ scanned with OKEN Scanner

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