settingsAccountsettings
Menusettings

Q: Integer Types Task - how many years, days and hours are in 20 centuries

+4 votes

I need to print out in Console Application in C# - how many years, days and hours are in 20 centuries.

It must be optimized for speed so I need to use different Integer Types (sbyte, byte, ushort, short, int, uint, long and ulong) for the centuries, years, days and the hours. Not only using long as an integer type.

asked in C# category by user Jolie Ann
edited by user golearnweb

2 Answers

+2 votes
 
Best answer

Here is the code:

using System;

class IntegerTypesTask
{
    static void Main()
    {
        byte centuries = 20;
        ushort years = 2000;
        uint days = 730480;
        ulong hours = 17531520;

        Console.WriteLine("{0} centuries is {1} years, {2} days and {3} hours.", centuries, years, days, hours);
    }
}
answered by user andrew
edited by user golearnweb
sweet! tahnk you
+2 votes

Jolie, use this table:

integer types in c sharp - table

answered by user mitko
edited by user golearnweb
...