According to the C++23 standard, what is the output of this program?
#include <iostream>
int main() {
int i = 42;
int j = 1;
std::cout << i / --j;
}What happens when you divide an integer by zero?
The program is (or may be) undefined
Integer division by zero is undefined behaviour. According to §[expr.mul]¶4 in the standard:
If the second operand of
/or%is zero the behavior is undefined.