Chapter2_3-Operators

The right side may be either literal ex i 1 variable

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: he right side of the operator to the variable appearing on the left side of the operator. • The right side may be either: • Literal: ex. i = 1; • Variable identifier: ex. start = i; • Expression: ex. sum = first + second; Page 11 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP Assigning Literals • In this case, the literal is stored in the space memory allocated for the variable A. Variables are A. Variables are A. at the left side. allocated in memory. allocated in memory. A A int firstNumber=1, secondNumber; firstNumber = 234; B B secondNumber = 87; firstNumber secondNumber 11 ??? ??? B. LLiteralsare B. iterals are B. assigned to variables. assigned to variables. Code firstNumber secondNumber 234 87 State of Memory Page 12 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP Assigning Variables • In this case, the value of the variable at the right side is stored in the space memory allocated for the variable at the A. Variables are A. Variables are left side. A. allocated in memory. allocated in memory. firstNumber i A A int firstNumber=1, i; firstNumber = 234; i = firstNumber; B B 11 ??? ??? B. vvaluesare assigned B. alues are assigned B. to variables. to variables. Code firstNumber i 234 234 State of Memory Page 13 Dr. S. GANNOUNI & Dr. A. TOUIR Introduction to OOP Assigning Expressions • In this case, the result of the evaluatio...
View Full Document

Ask a homework question - tutors are online