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

19 views3 pages
4 Feb 2017
School
Course
Professor

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&
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&&
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.