Hi, I was trying to do a small program in which you have to insert two numbers and the operation you want to do and it gives you the result. i got to a point where i created variables num1 num2 and num3 = num1 + num2
I thought it would use the numbers I give to him with cin to make num3 but instead it uses random numbers. I hope you can help me.
(P.S. don't mind italian text)
int num1;
int num2;
int num3 = num1 + num2; //garbage value
this is where it's wrong, you don't initialize num1 and num2, so they are going to be garbage values at first, then num3 will remain a garbage value because you summed 2 garbage values.
to fix it, you have to input num1 and num2 before summing num3