Video:How to Use Expressions and Statements in C++with Bulk Item
An 'expression' is something that is evaluated, and has an output to test if it's true or false. In this About.com video, learn what an expression and statement is in C++.See Transcript
Transcript:How to Use Expressions and Statements in C++
Hi, my name is Matt from Lordmatt.co.uk and I am here today for About.com to explain about expressions and statements in C++.
What is an Expression in C++?
An expression is something that is evaluated and has an output or is tested to be either true or false. For example, if I make an expression one equals two, it will evaluate it to false. And these expressions are used to test conditions in C++ and to make decisions.
What is a Constant?
Now, a constant is a value defined. They should not be confused with variables where you assign values. Constants are values that you set at the beginning and that will never change. Now, time conversions are quite important in C++ because if you are going to be going between one type of variable and another, you need to be able to convert them accurately.
If I was to cast a double to an integer, I am going to lose degrees of precision. And so having converted my times, having compared them with expressions, having used constants in my expressions I need to be aware that there is an operator precedence and the various operators, plus, minus, divide, multiply, are carried out in a certain order. We do not simply read the expression from left to right, but we evaluate it in the order of operators.
My name is Matt, thanks for watching, for more information you can go to the About.com C and C++ website.