Two identical codes when launched on two different computers give two correct answers that look different. How can this be explained? The goal of the program is to calculate А + В.Input: 1,000,000,000,000,000,000. Output-1: 2,000,000,000. Output-2: 2e + 009
#include <iostream> #include <fstream> using namespace std; int main(){ ifstream cin("input.txt"); ofstream cout("output.txt"); int a, b; cin » a » b; cout « a + b; return 0; }
I tried the code:
#include <iostream> int main() { std::cout << (int)2000000000; return 0; }
It is displayed as 2000000000.
Now I tried again to open the same code in another document, now it is displayed as 2000000000. What is unclear about this, but now everything is fine, thanks to everyone for their help.