Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
3 views
The Memory Address
Uploaded by
Rajeev Shrestha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save The Memory Address For Later
Download
Save
Save The Memory Address For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
3 views
The Memory Address
Uploaded by
Rajeev Shrestha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save The Memory Address For Later
Carousel Previous
Carousel Next
Save
Save The Memory Address For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 16
Search
Fullscreen
ports ak 1 Deffne a pofnter wTth 78 syntax. List out the features of Pointers: A Programm pofater fo programmrng, fsa stores the memory address varfable +hat ft allows fndfrect QJ another varfaple - access +0 the value OV data stored at that memory toca tfon Syntax a Deciaie data_type *po?nrer_-name © address o} HASSIGN + 1 pofnter-name = Fvarfaple ; 7 y : fat num = 42: fn+PoPorer = ~num; Access yosue 40 the 5 pot value = *pomnter_name Byample = gar fos value = *fntPoPnter; fy the value ecinted ¥ pofhrer_name = name_new-vatue! “ExOmplet *fhtPofntey = 99;. Ie . ' atures: Oo; po?nters : : of : uy | Saves _memory Space + Pofnters save space by Storfng addresses fnstead of valves, Conserv?ng, memory. "| Faster fyecuHon Trme «_ (Pofnters offer qufcker access to memory. bypa- Ssfag Name lookups: We) Cer Rent memory Access |Pofniers enhance memory access eftPcfency, fdead for arrays and structures: | | My | Pyname memory Allocatfon | Pofhiers enable changing Memory allocatfon durfog runtime , useful “when needs vary. ve Use with data structure Pofnreres afd fn data. _structore Man vputatfon, \?ke Ifnted lestS-and trees.2: WUrPte Short notes on the address C¥¢) and frnd?rectfon C*) operators The Address operator CL) TRe address operator Ps Unary operator frat retunes the address Of PFS operand. TRe ‘operand can be varfaple, an array element, Ora functfon. The address operator #s often Used to pass arguments by reference , to access arry elements, or to Aynamfcally allocate memory: ‘The Indfratfon operator C*) iTRe fndfrectfon operator fs unary operator that Ireturns the valve Of the opfect to PKS opera- Ind pofnts. The operand must bea pofnter | varfavie -Tne fnafrectfon operator fs Often value Of a varFable Fhrough used +0 access a pofnter , or 40 dereference a pofnter ail ee4 Explafn cai by vaiue and call by reference WF an example. > Cau by value and Call by reference are tW00 Methods of passfng arguments to functfons (5 Cay by valve: Call by value means thak the | value of the argument fs Coptd fnto the parameter. Any changes made to the param- eter rhsfde the functPon do NOt AFFect tne orfginad Arg: *Here fs an example 0g Cal by value: -vofa swap Cfhra ,ftod¢ fat temp? temp = as ab b= +emp; fat mafn Og | fnt A= Loe y=20; | /£€0\) the swap qo , pass Swap lays lap > value of FY | iprfnte Ca = ANY, X)s |prrnre (hy > %~ANMS yds ‘yeturn 0; iae es (Cain by reference t /Means that tne address of tne argumenr Ps | Passed Fnto tne parameter, Any changes (Made to the parameter fnsfae the functfon |OFFect tne orfgfna) argument: Here Ps an example of call by reference > Vora swap Cfnt %a, fat *d)& | fot temps temp = Fos Fat mafn tis Pat A=lo Y= 205 |? ass the addresses of Swap Carty): eos prfneg CM x= Zdlors X)y PrentpC'y= Zio", yd, return 03 2 ° 3 In generas, call by reference fF + all by value, bec yfno tne valu by reference use Pt alle4fPociude
+frnciude
vord mafod) & fat a,*p; GMES CTC )5 Prfnt fc" Tne address of afs %U\NY, FQ )s prihtf( THe address of p PS 7% UIN", Fp); P=$a5 prPntfc" The address of A US?no pofnter fs PUNY PIS Bat *, | prPnteC' The address of A After Pacrement of pornter Ps YUAN” ,P)s Prfnrf(" Enter the Value of a tObe Btoredln); SCAN FCN Md) Fas prfnréc'\ The value of ats %d\n",a); printf ('The value of a usfng’ oot Red | M0", BE AC20) |) PrNIFC” The value of a using pofoter Fs ao) eetchc): 5“The address of a fs 65524 The Address of p fs 65522 The address of a using pomter = 65524 THe address of a agter Fncremend fs 65526 Enter the value of & to be stored 4o4 TRe vaive of a Ps 404 The vawe of a usfng ¥ operator fs 104 The vaive of a pofnrer ?s 0. 2 The "L" operator , when used With pofnters , Allows Us to retrfeve the Memory Jocatfon / address 0g a varfaple. when combined WF the "¥)' Operator (deference dereference operaror). P led leks us access the valve Sfored at thar memory address - (RE )= that pofnter mahfpulott Pres carer mer Jstonm ) *+ WAP to cae cPeperent ar?thmetfe operatfons (AS addfifon, subtractfon ¢ MUliPpfearPon usthg Pofnters | H¥aclude estdfo:n> vod performOp C fat a, Pn+b, Tht *sum, fot “PPE, fo+ * Prod ) § | *sum= Atos * | *dPep = a-b: ALS 2 SO Pte. ten aa * prod =a 5 3 *e? * V fot math cg Fat n3,n2,sum, arte. Prod; Prfnte CYEMter two numbers +» "), SCANFC nd Vd"s $NL,FN2), performOp (ni,n2, Ssum, saree 4 prod): Prfarf CVSuM? %AIn"), sum), printf CY DPFFerence = ¥d\nY Ppl printf C“Product td eo eas return 0; is Ps 4| Obfectfue +2 2:1 = Pofprer wth one-dafmensfona) array | Code: | Hfhclude
| fnclude
| VORA maPn () |S frnt a 053=$1,2,3,4,5 44 PS | for CP= 0, F624 7 Prt] } 3 betcnc) ; | $ | Oorput ! Enter no-vaive of Adaress of Elements - = QloJ = 65933 Qf!1-65520 2 @e2)=- 68522 ac34= 65524 4 Q@C43- 6s526 5 | printhcu Element no- value of Address oJ 1-9) | | prfoiectalydI=l\kn Su 79e"y Rcat?), *Catt)); | |BAM Modtiiedy gan St Hea e cstafon> \# fncluge cconforn> votd mafne) | In+ fete number 2: fnr ats; |" Get the frie no from the user [prfotec' Enter the frie N02) [SCAN F CVG", BFPIeE-nuMber), ty PorHalfze the array wth 4ne numbers from Me fri. | for F=0: P55 THHS | 3 acra= Frle-number +i5 | 1.DRspiay tne content of the array using tne name | OF the avroy Pnseif as a pofnter | prfbtec'Lsing the name of the array Ptseie | as a pofpter :1n"); | “prPnte CY Enter no- valve OF Address of Bleminy:| idee CPO; Peed, FH IS prentpevatyarabBu 7d in F/AtPy *ca rt) oe 5 | |i OBplay ine content of array vsfng a Pofhicr) | fot *ptr=a, | ipinve crn Usfng a pofnrer # AN), | prfoth ("enter no - vave ef Address of Clem \0 : Lee — ————— — — sieges |FforC Peo} Pe=a 5 Pry PrfDHFCVACyAI=\en su valay, P, pirat, ¥Cprr +P): ¥ | 35 eH C)) 49 Output! ‘Enter the fPle number 3 do4 ntermo value Address Of lemenss: (07: 65514 404 C1- 65516 405 C2I1= 65518 4o6 €3)= ossz0 . 407% Ac43= 65522 4©3 sfng a pofnter: Enferno-value Address Of Elemrsents - Coy: 1436 -22 CL1= £439 0 C21~ 1940 oe C63= j4q2 0 C49= 9444 O ssfng the Name Of tne array Piselfas apotniey[3.42 Cau bY Value | [yp anciude
| ly foclude
| | yora SWAP C Fak x, Fa4y); yota Marni fat a= 80, b=90; prof’ valve OF A ana be before swapp?ng PE Yd “nd in "aib); eswapCarb); printf C" Value of aand od afier swapeng PS Fdlt XA\N4 arb); gerenO)y y vord SWaP (inata, Pat be int temp 4 demp=a}; azb, b= temp, 5 Output" vaive of cand b¢ befow swapprng Ps 30 20 value Of Gand od afrert swapprng Fs 30 20i lo (9-22 BY Telcrengs 7 pfoclude
ja fncivde
ju fnciude Z2Stdlib-n> vota mafnt)¢ font *P: n=5, 75 Z | | pe(Pnt¥”) matioe CePzeoF irr) *n) » iprfntec “Enter Frve numpersin), |For CP=O; Pen; PtH < SCONE C7, Cpr Pl): y for cP=0; Pen ;Pmg Prin thts DIE’ AER) 1S 7 gerchcs, g | Botput: | Enter frve numbers.|4efaclude
|4 fnclude ¢ StdiPb- h> fat mafnc) ¢ fnt n, *arr, ?,sum=0; PIPHEC Enter tne no. of maturad number : sant Curd', én): /lallocate memory Jor the array ‘ary = Cfnt¥) mahoc cn *sPee-of cPntJ); for CPO; Pen! pHs GQEF ATV EPI = PHL 5 fnd the Sum of the array elements for CP=0; PEN; TH), Sum+ = arrciy: | 1 Cadculate the average | Float aug = sum/n, yy | | | | Prfatece Sum of the first 7d naturalno Fs yen) Nsom), jetnte cu Tne average of me frrsk yd natural No- Ps re 2pin''s O1 avg) ; 5, return 0; 5 ee ourpur: Enter the number Ob frrst S Watural nO: 5 The sum 0b Ffrst S Natural no Ps LS The average Of the frst S naturods no Ps 3:00 | |
You might also like
unit 4 pps
PDF
No ratings yet
unit 4 pps
11 pages
Call_by_value_Pointers_explaination
PDF
No ratings yet
Call_by_value_Pointers_explaination
19 pages
UNIT-1_PSTC
PDF
No ratings yet
UNIT-1_PSTC
25 pages
Unit5 FileHandling
PDF
No ratings yet
Unit5 FileHandling
14 pages
Assembly 3
PDF
No ratings yet
Assembly 3
19 pages
C Programming Notes Part 3
PDF
No ratings yet
C Programming Notes Part 3
24 pages
C Language Notes-2
PDF
No ratings yet
C Language Notes-2
40 pages
BCS402-model-paper-set-1solution
PDF
No ratings yet
BCS402-model-paper-set-1solution
41 pages
Tuto No 01 Solution Up
PDF
No ratings yet
Tuto No 01 Solution Up
15 pages
Pointers Notes - 231208 - 151350
PDF
No ratings yet
Pointers Notes - 231208 - 151350
28 pages
Yash Ds
PDF
No ratings yet
Yash Ds
64 pages
C08 Psap PPT2 21221
PDF
No ratings yet
C08 Psap PPT2 21221
41 pages
Review of Arrays: Array Name
PDF
No ratings yet
Review of Arrays: Array Name
43 pages
En3es28_apc Lab Manual
PDF
No ratings yet
En3es28_apc Lab Manual
75 pages
DD
PDF
No ratings yet
DD
29 pages
មេរៀនទី 11-Dynamic Data Structures
PDF
No ratings yet
មេរៀនទី 11-Dynamic Data Structures
19 pages
EcE 22014, CH 7 All
PDF
No ratings yet
EcE 22014, CH 7 All
51 pages
Pointers
PDF
No ratings yet
Pointers
37 pages
Intro To Pointers Call by Val and Ref
PDF
No ratings yet
Intro To Pointers Call by Val and Ref
20 pages
Bba Solution
PDF
No ratings yet
Bba Solution
15 pages
KE06603 Engineering Programming: Lecture 14: Pointers
PDF
No ratings yet
KE06603 Engineering Programming: Lecture 14: Pointers
20 pages
C Language {Unit 2(Part 1)}[1]
PDF
No ratings yet
C Language {Unit 2(Part 1)}[1]
20 pages
C Programming
PDF
No ratings yet
C Programming
42 pages
BERC 1313 Lab 5 POINTER - 2022 - 2023 - Sem2
PDF
No ratings yet
BERC 1313 Lab 5 POINTER - 2022 - 2023 - Sem2
15 pages
Intro of Pointer
PDF
No ratings yet
Intro of Pointer
7 pages
Pointer
PDF
No ratings yet
Pointer
48 pages
0032_lab activity 1
PDF
No ratings yet
0032_lab activity 1
7 pages
MIPS Assembly Tutorial by Daniel J Ellard
PDF
No ratings yet
MIPS Assembly Tutorial by Daniel J Ellard
97 pages
Unit - Iii: Malla Reddy Engineering College For Women
PDF
No ratings yet
Unit - Iii: Malla Reddy Engineering College For Women
35 pages
Pointers, Call-By-Value, Call-By-Reference (DM)
PDF
No ratings yet
Pointers, Call-By-Value, Call-By-Reference (DM)
17 pages
CSC 1401 Lab Manual (Lab 9)
PDF
No ratings yet
CSC 1401 Lab Manual (Lab 9)
5 pages
C Language Notes-1
PDF
No ratings yet
C Language Notes-1
41 pages
3.Recursion_Answers
PDF
No ratings yet
3.Recursion_Answers
61 pages
3. DSA
PDF
No ratings yet
3. DSA
70 pages
lec 21 Pointers in C
PDF
No ratings yet
lec 21 Pointers in C
35 pages
DS Module 1 Solutions
PDF
No ratings yet
DS Module 1 Solutions
59 pages
Computer Programming Laboratory Experiment # 1: Pointers I Objectives
PDF
No ratings yet
Computer Programming Laboratory Experiment # 1: Pointers I Objectives
5 pages
EC CODING new_merged
PDF
No ratings yet
EC CODING new_merged
66 pages
ansh dsa
PDF
No ratings yet
ansh dsa
69 pages
Oodp Unit 1
PDF
No ratings yet
Oodp Unit 1
38 pages
Lecture 08 - 2024-1
PDF
No ratings yet
Lecture 08 - 2024-1
125 pages
ASGMNT 2 Edited
PDF
No ratings yet
ASGMNT 2 Edited
14 pages
Pointers
PDF
No ratings yet
Pointers
90 pages
Pointers
PDF
No ratings yet
Pointers
18 pages
2019july
PDF
No ratings yet
2019july
4 pages
Fundamental of Computer Programming: Lab - 10 Waqas Khan
PDF
No ratings yet
Fundamental of Computer Programming: Lab - 10 Waqas Khan
28 pages
Byts Week - 4
PDF
No ratings yet
Byts Week - 4
18 pages
Review On Embedded C
PDF
No ratings yet
Review On Embedded C
37 pages
Pointers
PDF
No ratings yet
Pointers
20 pages
Dynamic Memory Allocation: Free. There Is Also Sizeof Function Used To Determine The Number of
PDF
No ratings yet
Dynamic Memory Allocation: Free. There Is Also Sizeof Function Used To Determine The Number of
9 pages
Pointers
PDF
No ratings yet
Pointers
6 pages
EST102 - M5 - Ktunotes - in
PDF
No ratings yet
EST102 - M5 - Ktunotes - in
23 pages
Programming Keys
PDF
No ratings yet
Programming Keys
20 pages