2
I made the following program below that guess the age of the person and the number that she thought, but the final result generates a number of 4 digits according to the calculations below suppose I have thought of the number 12:
Multiply by 2: 12*2=24
add 5: 24+5=29
Multiply by 50: 29*50=1450
std::cout<<"Digite o rsultado: 1450";
std::cin>>result=1450;
int var1(2017-250);
int var2(1450+1767);
std::cout<<"\n\tDigite seu ano de nascimento: ";
std::cin>>anonasc;
int var3(3217-1994);
The result contained in var3 would be 1223 where 12 would be the number I had thought and 23 my age, however it has some way of separating this result so that it shows separately the number thought and the age of the person?
I know if I do:
var3=1223/100;
he returns me
var3=12
but for me to get number 23 like I do?
worked here but wanted to understand why number%50?
– dark777
number % 50
is the same as1223 % 50
– NoobSaibot
I know that I understood but why 50 and not any other number?
– dark777
That’s a question I can’t answer, but you can open a question, and someone with experience in
C++
answer you correctly.– NoobSaibot