
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
Advertisements