FIT3042 Lecture Notes - Lecture 4: Call Stack, Standard Streams, Logical Conjunction
L4: More about C
C Variables
●Must be declared before use
●Done at the start of the funcon
●Variable types are set at compile me and can’t change - stacally typed
C Data Types
●Not guaranteed to be of a fixed sized
●Base data types in order of size:
○Integer: char, short, int, long, long long
○Floang point: float, double
Variable Scope
●Visibility
●Global scope: declared outside a funcon
●Block scope: declared in curly braces within a funcon
●Local variable: declared within the braces surrounding a funcon body
●File scope: declared with a stac modifier outside a funcons
C Operators
● = : assignment
●+, -, *, ? : add subtract, mulply, divide
●- : megaon
●% : modulus
●++. -- : increment, decrement
●==, != : equals, not equals
●< , >, <= , >= : less than, greater than, less than or equal, greater than or equal
●&&, ||, ! : logical AND, OR, and NOT
Document Summary
Do(cid:374)e at the sta(cid:396)t of the fu(cid:374)(cid:272)(cid:415)o(cid:374) Va(cid:396)ia(cid:271)le t(cid:455)pes a(cid:396)e set at (cid:272)o(cid:373)pile (cid:415)(cid:373)e a(cid:374)d (cid:272)a(cid:374)"t (cid:272)ha(cid:374)ge - sta(cid:415)(cid:272)all(cid:455) t(cid:455)ped. Not gua(cid:396)a(cid:374)teed to (cid:271)e of a (cid:454)ed sized. Base data t(cid:455)pes i(cid:374) o(cid:396)de(cid:396) of size: I(cid:374)tege(cid:396): (cid:272)ha(cid:396), sho(cid:396)t, i(cid:374)t, lo(cid:374)g, lo(cid:374)g lo(cid:374)g. Blo(cid:272)k s(cid:272)ope: de(cid:272)la(cid:396)ed i(cid:374) (cid:272)u(cid:396)l(cid:455) (cid:271)(cid:396)a(cid:272)es (cid:449)ithi(cid:374) a fu(cid:374)(cid:272)(cid:415)o(cid:374) Lo(cid:272)al (cid:448)a(cid:396)ia(cid:271)le: de(cid:272)la(cid:396)ed (cid:449)ithi(cid:374) the (cid:271)(cid:396)a(cid:272)es su(cid:396)(cid:396)ou(cid:374)di(cid:374)g a fu(cid:374)(cid:272)(cid:415)o(cid:374) (cid:271)od(cid:455) File s(cid:272)ope: de(cid:272)la(cid:396)ed (cid:449)ith a sta(cid:415)(cid:272) (cid:373)odi e(cid:396) outside a fu(cid:374)(cid:272)(cid:415)o(cid:374)s. < , >, <= , >= : less tha(cid:374), g(cid:396)eate(cid:396) tha(cid:374), less tha(cid:374) o(cid:396) e(cid:395)ual, g(cid:396)eate(cid:396) tha(cid:374) o(cid:396) e(cid:395)ual. Stdi(cid:374), stdout, stde(cid:396)(cid:396) sta(cid:374)da(cid:396)d st(cid:396)ea(cid:373) fo(cid:396) i/o - de (cid:374)ed i(cid:374) stdio. h. Sp(cid:396)i(cid:374)(cid:414) - (cid:449)(cid:396)ites to a spe(cid:272)i ed (cid:272)ha(cid:396)a(cid:272)te(cid:396) a(cid:396)(cid:396)a(cid:455) i(cid:374) (cid:373)e(cid:373)o(cid:396)(cid:455) This (cid:373)a(cid:455) (cid:271)e the add(cid:396)ess of a(cid:374)othe(cid:396) (cid:448)a(cid:396)ia(cid:271)le. Si(cid:373)ila(cid:396) to (cid:272)lasses i(cid:374) p(cid:455)tho(cid:374) a(cid:374)d ja(cid:448)a. A(cid:396)(cid:396)o(cid:449) ope(cid:396)ato(cid:396) fo(cid:396) a(cid:272)(cid:272)essi(cid:374)g th(cid:396)ough a poi(cid:374)te(cid:396) Whe(cid:374) a fu(cid:374)(cid:272)(cid:415)o(cid:374) (cid:272)all o(cid:272)(cid:272)u(cid:396)s a(cid:374)d (cid:374)e(cid:449) sta(cid:272)k f(cid:396)a(cid:373)e is added to the (cid:271)o(cid:425)o(cid:373) of the sta(cid:272)k.