
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
Evaluation order of operands in C++
There are some rules in programming that govern how an operation is performed.
The order of evaluation of operation and the associativity of operations (which is left to right is defined).
Here is a program to show the evaluation order of operands,
Example
#include <iostream> using namespace std; int x = 2; int changeVal() { x *= x; return x; } int main() { int p = changeVal() + changeVal(); cout<<"Value: "<<x<<endl; cout<<"Operation result: "<<p<<endl; return 0; }
Output −
Value: 16 Operation result: 20
- Related Articles
- Order of evaluation in C++ function parameters
- What is evaluation order of function parameters in C?
- Evaluation of Boolean expression
- Evaluation of Prefix Expressions in C++
- Evaluation of Expression Tree in C++
- Numbers and operands to words in JavaScript
- Evaluation of Risk in Investments in C++
- What are the types of Operands fetch Policies?
- Elaborate the legal operands of the instance of operator in java?
- Short-circuit evaluation in JavaScript
- ICT in Assessment and Evaluation
- Alternative Evaluation In Buying Decisions
- What are Instruction Codes and Operands in Computer Architecture?
- What are the schemes for checking the availability of operands?
- Explain the evaluation of expressions of stacks in C language

Advertisements