CS 24000 Study Guide - Midterm Guide: Entry Point, In C, Octal

19 views3 pages

For unlimited access to Study Guides, a Grade+ subscription is required.

CS240&Lecture&4&Notes&review&2&&
Constants'
Same&as&Java.&&
const double PI = 3.14192654;
Constants&cannot&be&changed&&
Also&it&is&common&in&C&to&use&the&C&pre-&processor&to&define&variables&&
#define PI 3.14192654
&
Assignments'
The&element&in&the&left&side&has&to&be&an&“l-value”.&An&“l-value”&can&be&
interpreted&as&an&address.&&&
A&variable&is&an&l-value&but&a&constant&is&not&an&l-value.&
o x&=&5;&←&l-value&&
o 8&=&5;&←&not&l-value&&&
In&C,&an&assignment&is&an&expression&&&
This&implies&that&an&assignment&may&appear&anywhere&an&expression&is&
&allowed.&Example:&&&
j = (i = 5) +3; // this will assign 5 to i and it will
assign 8 to j. !
Example:&&
while( (c = getChar() ) != -1){ ... } !
&
The'main'program'
Execution&starts&in&main&&
int main(int argc, char**argv){
}!
or
!int main(){
!}
argc-store#ofargs.&&
argv-it&is&an&array&of&the&argument&entries&as&strings.&&
int main(int argc, char**argv){
int i;
for(i = 0; i <argc; i++){
!printf(“argv[%d] = %s\n, i, argv[i]);
}
}
&
Integer'constants'
Integer&Constants&&
o 1&2&3&4&→&decimal&&
o 031&→&octal&constant&3*8+1&=&25&Starts&with&0&&
o 0x4A3&→&hexadecimal&constant&4*16^2+10*16+3=&or&in&binary&0100&
1010&0011&&
The&type&of&integer&constant&will&be:&&
o int&→&if&v&does&not&exceed&the&int&range.&&
Unlock document

This preview shows page 1 of the document.
Unlock all 3 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+
$10 USD/m
Billed $120 USD annually
Homework Help
Class Notes
Textbook Notes
40 Verified Answers
Study Guides
1 Booster Class