Challenge 5
Page 1 of 1
Challenge 5
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.
Re: Challenge 5
int centuryFromYear(int year) {
int century;
if (year % 100 == 0) {
century= year / 100;
} else {
century = (year / 100) + 1;
}
return century;
}
int century;
if (year % 100 == 0) {
century= year / 100;
} else {
century = (year / 100) + 1;
}
return century;
}
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|