Answer to Question #231843 in C++ for Shangavi

Question #231843
Re writie the code with the statement ++ you can only addor modify statements a,b,c
1
Expert's answer
2021-09-01T03:00:35-0400
#include <iostream>


int main()
{
    int a{ 10 };
    int b{ 12 };
    int c{ 15 };

    std::cerr << "a="<<a<<std::endl;
    std::cerr <<"Let's execute a++" << std::endl;
    a++;
    std::cerr << "a=" << a << std::endl;
    std::cerr << std::endl;
    std::cerr << "b=" << b << std::endl;
    std::cerr << "Let's execute ++b" << std::endl;
    ++b;
    std::cerr << "b=" << b << std::endl;
    std::cerr << std::endl;
    std::cerr << "a=" << a << " b=" << b << std::endl;
    std::cerr << "Let's execute c = a + ++b" << std::endl;
    c = a + ++b;
    std::cerr << "a=" << a << " b=" << b << " c=" <<c<<std::endl;
    std::cerr << std::endl;
    std::cerr << "a=" << a << " b=" << b << std::endl;
    std::cerr << "Let's execute c = a +b++" << std::endl;
    c = a + b++;
    std::cerr << "a=" << a << " b=" << b << " c=" << c << std::endl;
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS