Chapter Summary

I l @ ve RuBoard

Chapter Summary

C has many operators, such as the assignment and arithmetic operators discussed in this chapter. In general, an operator operates on one or more operands to produce a value. Operators, such as the minus sign and sizeof , that take one operand, are termed unary operators . Operators requiring two operands, such as the addition and the multiplication operators, are called binary operators .

Expressions are combinations of operators and operands. In C, every expression has a value, including assignment expressions and comparison expressions. Rules of operator precedence help determine how terms are grouped when expressions are evaluated.

Statements are complete instructions to the computer and are indicated in C by a terminating semicolon. So far, you have worked with declaration statements, assignment statements, function call statements, and control statements. Statements included within a pair of braces constitute a compound statement , or block . One particular control statement is the while loop, which repeats statements as long as a test condition remains true.

In C, many type conversions take place automatically. The char and short types are promoted to type int whenever they appear in expressions or as function arguments. The float type is promoted to type double when used as a function argument. Under K&R C (but not ANSI C), float is also promoted to double when used in an expression. When a value of one type is assigned to a variable of a second type, the value is converted to the same type as the variable. When larger types are converted to smaller types ( long to short or double to float , for example), there might be a loss of data. In cases of mixed arithmetic, smaller types are converted to larger types following the rules outlined in this chapter.

When you define a function that takes an argument, you declare a variable , or formal argument , in the function definition. Then the value passed in a function call is assigned to this variable, which can now be used in the function.

I l @ ve RuBoard


C++ Primer Plus
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2000
Pages: 314
Authors: Stephen Prata

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net