Question: Instructions: Written in C. The variable to be tested, year , should be a hard-coded parameter. Also, within your programs comments, indicate a set of
Instructions: Written in C. The variable to be tested, year, should be a hard-coded parameter. Also, within your programs comments, indicate a set of test values that would exercise all four possible outcomes of the if statements.
ex: The year 2016 WAS a leapyear!
Sorry, the year 1900 was NOT a leapyear.
My code:
int main(void)(
float year; = 2012 float leapyear = (year%4)
// assume that it is not a leapyear, try to determine otherwise bool leapyear = false;
if (year%4) == 0 leapyear = true; end
if (year%100) == 0 leapyear = false; end
if (year%400) == 0 leapyear = true;
if leapyear disp(['The year ' num2str(year) ' WAS a leap year!']); else disp(['Sorry, the year ' num2str(year) ' was NOT a leap year.']); end
fprint('')
leapyear
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
