I am new to c#, I have written this code that calculates number of days out of number of hours. But the problem is when I input 25 hours, the value in the hours field is saved as 50 i.e. double of the actually entered value. Can someone help me about this.
int hours, numberOfDays = 0;
Console.WriteLine("Please enter number of hours => ");
hours = Convert.ToInt32(Console.Read());
numberOfDays = hours/24;
int hoursLeft = hours%24;
Console.WriteLine("Number of days => {0}", numberOfDays);
Console.WriteLine("Number of hours left => {0}", hoursLeft);
Console.ReadKey();


Sign In
Create Account

Back to top









