课程: Complete Guide to C++ Programming Foundations

免费学习该课程!

今天就开通帐号,24,100 门业界名师课程任您挑!

Statements and expressions

Statements and expressions

- [Instructor] Let's move on to discussing statements and expressions. in C++. A statement is a unit of code that performs an action. In other words, a statement might do something like declaring a variable, assigning a value to a variable, or calling a function. Each statement in C++ ends with a semicolon, which tells the compiler that the statement is complete. An expression is a combination of constants, variables, and operators that returns a value. Expressions can be as simple as a single variable or a constant, or they can be more complex combinations involving multiple operations and variables. The key thing to remember is that expressions produce a value. Now let's look at a practical example to demonstrate various types of statements and expressions showing how they work together to form a complete program. In line two, we have a declaration statement where we declare an integer, variable a, and initialize it with the value five. In line three, there's another declaration…

内容