MECH 215 Lecture Notes - Lecture 2: Integer Literal, Increment And Decrement Operators, Operand

42 views12 pages

Document Summary

The assignment operator in c++ is the = symbol. The assignment operator stores a result into a variable. The general form of the assignment operator is the following: variable = expression ; expression can be a literal value, another variable, or any syntactically correct expression in c++. In an assignment statement, the left and right hand operators should be of the same type. int x; float y; double z; x = 6; y = 2. 3; z = 5. 678; In the above expressions , the targets of the three assignment statements match the values which are being assigned to them. ( 6 is an integer literal, 2. 3 and. 5. 678 are valid float and double literal expressions respectively). In the case where the value of an assignment does not match the target type, the compiler will attempt to convert the right hand value so that its type matches that of the target.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents