0
Can i convert a variable to constant?
For example i enter 2 numbers into nember1 and number2. Then number1*number2=result So here i want to make the number2 constant then put the result into number1 It means. Each time that i press equal. Number2 stay constant but number1 hold the result then multiply it with number2
6 Answers
+ 1
So that means it would be like
num1 = x;
num2 = y;
ans = num1 * num2;
num1 = ans;
.
.
.
Is that what you mean?
0
Good day Diako! Can you elaborate your question a little bit more with example?
0
Sure. Its a calculator. When i enter two numbers as number1 and number2 and then multiply those two numbers and then when i click the equal button it shows me the result and then when i click on the equal button again it put the result into the number1 and multiply it with the number2 which i want it to be conatant
0
Each time that i click on the equal button it put the result in number1 then multiply it with number2
0
Yes but in that case you wrote. If i write 2*4 the answer is 8 but if i press equal again it would be 64 but i want that be 32
0
The calculator automatically comes and make the num2 to result and when you make the num1 to result it will be result * result