programming-examples/c++/Others/Arithmetic assignment operators.cpp
2019-11-15 12:59:38 +01:00

20 lines
574 B
C++

Arithmetic assignment operators
#include <iostream>
using namespace std;
int main() {
int ans = 27;
ans += 10; //same as: ans = ans + 10;
cout << ans << ", ";
ans -= 7; //same as: ans = ans - 7;
cout << ans << ", ";
ans *= 2; //same as: ans = ans * 2;
cout << ans << ", ";
ans /= 3; //same as: ans = ans / 3;
cout << ans << ", ";
ans %= 3; //same as: ans = ans % 3;
cout << ans << endl;
return 0;
}