Answer the question
In order to leave comments, you need to log in
Is the information in the book out of date?
The results of the code from the book by Vasiliev A.N. slightly disagree with his comment (and my reasoning based on his explanation). I scratched my turnips and did not come up with anything better than to write here. Please advise a book without such blunders on the first pages.
#include<iostream>
using namespace std;
int main(){
int n,m,i=3,j=3;
cout<<"At the beginning:\n";
cout<<"i = "<<i<<"\n";
cout<<"j = "<<j<<"\n";
cout<<"After command n=i++ :\n";
n=i++;// Теперь n=3, а i=4
cout<<"n = "<<n<<"\n";
cout<<"i = "<<i<<"\n";
cout<<" After command m=++j :\n";
m=++j;// Значение переменных m=4 и j=4
cout<<"m = "<<m<<"\n";
cout<<"j = "<<j<<"\n";
cout<<" After command n=(--i)*(i--) :\n";
n=(--i)*(i--);// Теперь n=9, а i=2
cout<<"n = "<<n<<"\n";
cout<<"i = "<<i<<"\n";
cout<<" After command m=(--j)*(--j) :\n";
m=(--j)*(--j);// Теперь m=4, а j=2
cout<<"m = "<<m<<"\n";
cout<<"j = "<<j<<"\n";
cout<<" After command n=(--i)*(i++) :\n";
n=(--i)*(i++);// Теперь n=1, а i=2
cout<<"n = "<<n<<"\n";
cout<<"i = "<<i<<"\n";
cout<<" After command m=(j--)*(++j) :\n";
m=(j--)*(++j);// Теперь m=9, а j=2
cout<<"m = "<<m<<"\n";
cout<<"j = "<<j<<"\n";
cout<<" After command n=(--i)*(++i) :\n";
n=(--i)*(++i);// Теперь n=4, а i=2
cout<<"n = "<<n<<"\n";
cout<<"i = "<<i<<"\n";
return 0;
}
Answer the question
In order to leave comments, you need to log in
Do you know how a book differs from source code documentation? In the first case, the code is not always up to date, and in the second, the text. If, when reading documentation, you should always keep in mind that it may be out of date, then when reading a book, the opposite is true. First of all, you need to delve into the meaning of what is written, and examples are just examples. No need to stupidly try to make the examples work, and then understand from the text what is happening there. We read it, realized it, we are trying to do it in our own way, but just peeping as an example.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question