Challenge 5

Go down

Challenge 5

Post by Admin on Mon Aug 28, 2017 4:33 pm

Given a year, return the century it is in. The first century spans from the year 1 up to and including the year 100, the second - from the year 101 up to and including the year 200, etc.
avatar
Admin
Admin

Posts : 25
Join date : 2017-08-17
Location : Torrance CA

View user profile http://southbayrobot.com

Back to top Go down

Re: Challenge 5

Post by Admin on Mon Aug 28, 2017 4:33 pm

int centuryFromYear(int year) {
int century;
if (year % 100 == 0) {
century= year / 100;
} else {
century = (year / 100) + 1;
}
return century;
}
avatar
Admin
Admin

Posts : 25
Join date : 2017-08-17
Location : Torrance CA

View user profile http://southbayrobot.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum