c++ is amazing

Revision en3, by virgil_van_maguire, 2025-01-06 14:29:07

guess the value of each of the following and explain your logic. (please don't run it, have fun guessing)

    int x=5;
    cout<< x++ + ++x<<endl;
    x=5;
    cout<< ++x + x++<<endl;
    x=5;
    cout<<++x + ++x<<endl;
    x=5;
    cout<<++x + ++x + ++x<<endl;

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English virgil_van_maguire 2025-01-06 14:29:07 41
en2 English virgil_van_maguire 2025-01-06 14:15:28 44 Tiny change: 'x<<endl;\n' -> 'x<<endl;\n x=5;\n cout<<++x + ++x + ++x<<endl;\n'
en1 English virgil_van_maguire 2025-01-06 14:12:58 218 Initial revision (published)