- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHPPhysics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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