This is the first of a series of C++ puzzles for you. Hope you will enjoy.
So, puzzle no.1:
Given the following program:
#include <iostream>
int main()
{
const int a=1;
const int b=2;
const float c=0.5;
std::cout << a/b-a*c;
}
Insert some code on a single new line anywhere inside the program so that the output will be 0. The new line will contain AT MOST 18 characters (including spaces), and the rest of the lines will remain unmodified. To be clear, here is an example of a valid new code:
#include <iostream>
int main()
{
const int a=1;
const int b=2;
int* p = NULL;
const float c=0.5;
std::cout << a/b-a*c;
}
A new line with 15 characters was inserted so it's ok. However it does not solve the problem.
If this is too simple for you, don't worry, more is coming!!