Explaining our code

The first section, Preprocessor Directive, gathers an iostream library so the code knows what to do with certain statements and can compile it.

The main function is a giant function with all the code that it needs to run in it.

The first set of expression statements print out backstory to the terminal.

The Declaration statements declare a series of variables for us.

The second set of expression statements print some of the variables out into the terminal for us.

Finally the return statement ends the code.

I’m a bit confused as to what the difference between expression statements and declaration statements are- if declaration statements have a statement and a semicolon, why aren’t they expression statement? Are they like a sub category of expression statement or something?

1 Like

The Preprocessor Directive is used in order to include certain tools that we might need in our program and it is put at the top of the file so the rest of the code can have access to it.

The main function is the initial start of our program and would expect a number to return once it is done running

The expression statements are there to output the story to our player.

The declaration statements are used to declare what variables we might need as well as their values.

The next set of expression statements are used to out put the values we had set to the sum and product variables.

The return statement sends back a 0 to the main function to tell it that it ran without any mistakes. (i think)

Same I was a bit confused as to the difference between expression and declaration statements.
I think you’re on it with the sub-category idea because I looked up to have more clarity and Declaration statements are only those that would define a variable.

Privacy & Terms