{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

02CIntroLarge - CMSC 106 Lecture Set#2 C Language...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CMSC 106 Lecture Set #2 C – Language Introduction C language – syntax square6 Syntax square6 rules of the grammar square6 vocabulary recognized by the language square6 ANSI standard square6 American National Standards Institute square6 Semantics square6 the meaning of what is being said
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 Syntax vs Semantics Examples square6 The monster scared Jon. square6 syntactically valid square6 Jon scared the monster. square6 syntactically valid square6 says something different than the first. square6 Jon sat in the chair. square6 syntactically valid square6 The chair sat in Jon. square6 syntactically valid square6 questionable in semantics square6 The in sat. Chair Jon square6 Syntactically invalid square6 no semantic interpretation from this available at all Program Errors square6 Incorrect Syntax square6 The compiler gives error message at that spot and refuses to compile it. square6 The compiler gives warning message at that spot but still compiles it. square6 The compiler gives error or warning message at a spot later in the file. square6 Incorrect Semantics square6 Program does nothing when run square6 Program does nothing useful when run square6 Program does the “wrong” thing when run square6 Program “crashes” or “hangs” when running
Background image of page 2
3 Basic Program Structure square6 a program must be comprised of 1 or more functions square6 function = named program part for performing a specific task square6 must be 1 and only 1 function named main square6 controls everything else square6 starts there and determines who gets to go when square6 for now this is the only function you’ll design Functions: Definition and Use square6 Syntax of a function definition: funct_type funct_name ( list_of_parameters ) { funct_body } Example of a complete program: int main(){ printf("this is a complete program\n"); } Syntax of a function call funct_name(list_of_arguments); Example of a function call: printf("This is a complete program\n");
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
4 Functions: Identified by Name square6 Identifiers square6 Used to name functions, variables, etc.
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}