Code 1:
#include <iostream>
int main(){
int a = 7;
std::cout<<++a*++a;
}
Output: 81
Code 2:
#include <iostream>
int main(){
int a;
std::cin>>a;
std::cout<<++a*++a;
}
Input: 7
Output: 72
I tried using scanf() and printf() but they are also giving me different results. I compiled these on g++ 4.8.4 and DevC++ and both behave the same way. Although on ideone both give the same output 81.
Why am I getting different outputs just by getting the value as an input?