Problem Description
Write a program that uses a structure called date that has it passed to an isLeapYear function to determine if the year is a leap year
Input and Output Format:
Example: 05 06 1978
Refer sample input and output for formatting specification.
All float values are displayed correct to 2 decimal places.
All text in bold corresponds to input and the rest corresponds to output
Mandatory:
1. Create a Structure "Year" and three variables as date(int), month(int), year(int)
2. Create structure variable as "s1"
Note: The structure variables, data members and structure name are CASE Sensitive.
Follow the same case mentioned in the mandatoryCODING ARENA::
#include <stdio.h>
struct Year
{
int date,month,year;
}s1;
int main()
{
scanf("%d\t%d\t%d",&s1.date,&s1.month,&s1.year);
printf("\nDate=%d",s1.date);
printf("\nMonth=%d",s1.month);
printf("\nYear=%d",s1.year);
if(s1.year%4==0)
{
printf("\n%d is a leap year",s1.year);
}
else
{
printf("\n%d is not a leap year",s1.year);
}
return 0;
}
Test Case 1
Input (stdin)5 6 1977
Expected OutputDate=5 Month=6 Year=1977 1977 is not a leap year
Test Case 2
Input (stdin)25 12 2000
Expected OutputDate=25 Month=12 Year=2000 2000 is a leap year
No comments:
Post a Comment