View Code of Problem 81

#include<stdio.h>
struct Time{
  int year;
  int month;
  int day;
} time;
int main()
{
  int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
    int i,k;
  scanf("%d%d%d",&time.year,&time.month,&time.day);
  if((time.year%4==0&&time.year%100!=0)||time.year%400==0)
  {
  k=1;
  }
  for(i=0;i<month-1;i++)
  {
  if(k==1&&i==1)
  {
   time.day+=a[i]+1;
  }
    else time.day=a[i];
  }
  printf("%d",time.day);
  return 0;
}
/*
Main.c: In function 'main':
Main.c:16:13: error: 'month' undeclared (first use in this function)
   for(i=0;i<month-1;i++)
             ^~~~~
Main.c:16:13: note: each undeclared identifier is reported only once for each function it appears in
*/

Double click to view unformatted code.


Back to problem 81