Programming in C++ W hat is in a heading ? type of returned value name of function says no parameters int main(
What is in a heading? int main ( ) type of returned value name of function says no parameters
Programming in C++ Block(Compound Statement a block is a sequence of zero or more statements enclosed by a pair of curly braces } SYNTAX Statement (optional) 12
12 Block (Compound Statement) ❖a block is a sequence of zero or more statements enclosed by a pair of curly braces { } SYNTAX { Statement (optional) . . . }
Programming in C++ Shortest C++ Program The syntax template allows the function body to have no statements at al type of returned value name of function int main( return 0; means everything were OK 13
13 Shortest C++ Program int main ( ) { return 0; } type of returned value name of function means everything were OK The syntax template allows the function body to have no statements at all
Programming in C++ What is an Identifier? An identifier is the name used for a data object (a variable or a constant), or for a function, in a C++ program C++ is a case-sensitive language Uppercase letters are different from lower letters susing meaningful readable identifiers is a good programming practice 14
14 What is an Identifier? ❖An identifier is the name used for a data object (a variable or a constant), or for a function, in a C++ program. ❖C++ is a case-sensitive language. Uppercase letters are different from lower letters. ❖using meaningful readable identifiers is a good programming practice
Programming in C++ Identifiers an identifier must start with a letter or underscore, and be followed by zero or more letters (A-Z, a-z), digits(0-9), or underscores VALID age of dog taxRateY2K PrintHeading ageOfHorse & NOT VALID(Why?) agei 2000Tax Rate Age-Of-Cat int Get Data 15
15 Identifiers ❖an identifier must start with a letter or underscore, and be followed by zero or more letters (A-Z, a-z), digits (0-9), or underscores ❖VALID age_of_dog taxRateY2K PrintHeading ageOfHorse ❖NOT VALID (Why?) age# 2000TaxRate Age-Of-Cat int Get Data