Given a year, return the century it is in. The first century spans from year 1 up to and including the year 100, the second - from the year 101 up to and including the year 200, etc.
Solution :
int centuryFromYear(int year)
{
int a = year / 100;
a++;
if(year % 100 == 0)
a--;
return a;
}
Solution :
int centuryFromYear(int year)
{
int a = year / 100;
a++;
if(year % 100 == 0)
a--;
return a;
}
Comments
Post a Comment