Now we need a program that reads an integer of type INT from the console (input is guaranteed to be INT) and then outputs its absolute value. You might write the following code with your eyes closed:

1
2
3
4
5
6
7
8
#include <iostream>

int main()
{
int n;
std::cin >> n;
std::cout << abs(n) << std::endl;
}

Wait a minute, think carefully for two minutes, and then run the program with a few test cases. Have you found the problem in the program? Well, welcome to the world of Undefined Behavior.