C++ what is wrong with my equation?

int AnswerNum = (((OriginalNum * 2) * 100) + OriginalNum);
cout << " Your Answer was: ";
cout << AnswerNum;

Probably not the best way to do this but it is the way i know how, which is apparently not the way to do it at all.

C what is wrong with my equation int AnswerNum OriginalNum 2 100 OriginalNum cout ltlt Your Answer was cout ltlt AnswerNum Probably not the best way to do this class=

Respuesta :

This (simplified) piece of code seems to work:

int OriginalNum;

int AnswerNum;

cout << "Insert your number: ";

cin >> OriginalNum;

AnswerNum = 201*OriginalNum;

cout << "The answer is:";

cout << AnswerNum;

If I copy what visible in your screen, the compiler complains about the variable OriginalNum not being declared. Try to paste my code and see if you have any issue.

Note: the expression OriginalNum*2*100 + OriginalNum is simply a multiplication by 201!

In fact, you have

[tex]x\mapsto 2x \mapsto 2x\cdot 100 = 200x \mapsto 200x+x = 201x[/tex]