0

Why isn't the practice code working? Everything should be correct, but both output values ​​are the same.

namespace SoloLearn { class Program { static void Main(string[] args) { int salaryBudget = Convert.ToInt32(Console.ReadLine()); int percent = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Before the increase: " + salaryBudget); Increase(ref salaryBudget, ref percent); Console.WriteLine("After the increase: " + salaryBudget); } static void Increase(ref int x, ref int y) { x = x * ((100 + y)/100); } } }

2nd Feb 2021, 2:47 PM
FogyX
FogyX - avatar
2 Respostas
+ 3
Make use of double types, expression "100+y/100" is always converted to 1 from 1.4 or something else.
2nd Feb 2021, 3:07 PM
Abhay
Abhay - avatar
+ 2
Damn, I completely forgot about data types. Thanks!
2nd Feb 2021, 3:09 PM
FogyX
FogyX - avatar