View Code of Problem 81

#include<stdio.h>
struct student
{
   int year;
   int month;
   int day;
}date;
int main()
{
  int days=0,i;
  int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
  scanf("%d %d %d",&date.year,&date.month,&date.day);
  if(i=0;i<date.month;i++)
      days=days+a[i];
  days=days+day;
  if(((year%4==0&&year%100!=0)||(year%400==0))&&date.month>=2)
        days=days+1;
  printf("%d",days);
  return 0;
}
  
/*
Main.c: In function 'main':
Main.c:13:3: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   if(i=0;i<date.month;i++)
   ^
Main.c:13:9: error: expected ')' before ';' token
   if(i=0;i<date.month;i++)
         ^
Main.c:15:13: error: 'day' undeclared (first use in this function)
   days=days+day;
             ^
Main.c:15:13: note: each undeclared identifier is reported only once for each function it appears in
Main.c:16:8: error: 'year' undeclared (first use in this function)
   if(((year%4==0&&year%100!=0)||(year%400==0))&&date.month>=2)
        ^
*/

Double click to view unformatted code.


Back to problem 81