BEGINNING PROG FOR ENG
BEGINNING PROG FOR ENG CSCI 1190
Popular in Course
Popular in ComputerScienence
This 3 page Class Notes was uploaded by Santos Fadel on Monday October 19, 2015. The Class Notes belongs to CSCI 1190 at Rensselaer Polytechnic Institute taught by Staff in Fall. Since its upload, it has received 37 views. For similar materials see /class/224858/csci-1190-rensselaer-polytechnic-institute in ComputerScienence at Rensselaer Polytechnic Institute.
Reviews for BEGINNING PROG FOR ENG
Report this Material
What is Karma?
Karma is the currency of StudySoup.
Date Created: 10/19/15
CSC171190 Beginning C Programming for Engineers Lecture 4 Arrays and Pointers Gang Chen ShortrCut Assignments ab aab a7b aaib7 ao aao a aab ao aao Expressions as Statements 0 Expressions can be directly used as statements 1 1 34 Postfix Increment and Decrement o Post x increment and decrement Operators return the original value of the variable then increment or decrement the variable int ab printf dn a f 10 printf dn a M 11 r printf dn b zquot 10 printf dn b f 9 Prefix Increment and Decrement o Pre x increment and decrement Operators increment or decrement the variable then return its resulting value int ab printf dn a W 11 printf dn a M 11 r printf dn 77b f 9 printf dn b f 9 Arrays An array an be viewed as a set of indexed variables with the same name Declared using the I notation to indicate the rangesize of the array Elements are indexed using the I notation ranging from 0 to one less than the bound int a5 m for 10 ilt5 i a i i l Using Arrays There are no human operarors t orarmys ilt5i b2 W o1lt X ilt5i Ciaibi zquot ok W error X W error X W error X Array lndices o ndices must be integers Multidimensional Arrays int ija5 3 fori0ilt5i forj0jlt3j ali jlij7 Ianlass Exercise 41 Pointers Pointers are variables that contain memory addresses as their values 1 int p 2 int 1 l j 2 a pampi r printf p dnquotp W D1 j a printf p dnquotp W D2 7 34 s Pri tf p dn p zquot p3 Arrays and Pointers o In many cases arrays and pointers are interchangeable snnu sum 3n smz sue Jnt am l l l Jnt p aml aUI 21 law m Pointers as Function Parameters void incremen nt a at void incremem Z nt ml WW mt mam wt 1 incrementm pnmmd return Arrays as Function Parameters mt sumomal mt n J equ walenno mt summt a mt n 7 wt 5 for 0 SUWZO Kn H 7 n return 3 mtmamo m mmoo fOrUZO K ch pHmf The total is mm xsumwoo Ianlass Exercise 42