Hai i am getting so many errors
Quote:
Originally Posted by
ferroz1
I did it but i dont know why is not working if anyone plz help me and tell me what to change because my program is not ending and the leap year (february which only has 29 0r 28 days is not working) plz help me
Code:
#include <stdio.h>
#include "header.h"
int isLeapYear(int year)
{
int isLeap = 0;
if((year % 4) == 0)
{
isLeap = 1;
if((year % 100) == 0)
{
isLeap = 0;
if((year % 400) == 0)
{
isLeap = 1;
}
}
}
return isLeap;
}
int getMonthDays(int month, int year){
int days = 0;
switch(month){
case 1: days = 31;
break;
case 2: if(isLeapYear(year) == 1)
days = 29;
else
days = 28;
break;
case 3: days = 31; break;
case 4: days = 30; break;
case 5: days = 31; break;
case 6: days = 30; break;
case 7: days = 31; break;
case 8: days = 31; break;
case 9: days = 30; break;
case 10: days = 31; break;
case 11: days = 30; break;
case 12: days = 31; break;
}
return days;
}
main()
{
char dummy;
int i, end_of_line, days_in_month=30;
while(dummy != 'N' || dummy != 'n')
{
printf("Please enter a year: ");
scanf("%i", &a.year);
printf("Please enter a month: (1=Jan, 12=Dec): ");
scanf("%i",&a.month);
while(a.month< 1 || a.month> 12){
printf("\n\nInvalid input: Enter valid input\n");
printf("Please enter a month: (1=Jan, 12=Dec): ");
scanf("%i",&a.month);
}
printf("Please enter the starting day of the month (1=Sun, 7=Sat): ", &a.starting_day);
scanf("%i", &a.starting_day);
while(a.starting_day < 1 || a.starting_day > 7)
{
printf("\n\nInvalid input: Enter valid input\n");
printf("Please enter the starting day of the month (1=Sun, 7=Sat): ", &a.starting_day);
scanf("%i", &a.starting_day);
}
printf("S\tM\tT\tW\tT\tF\tS\n");
switch (a.starting_day)
{
case 1: end_of_line=7;
break;
case 2: end_of_line=6;
printf("\t");
break;
case 3: end_of_line=5;
printf("\t\t");
break;
case 4: end_of_line=4;
printf("\t\t\t");
break;
case 5: end_of_line=3;
printf("\t\t\t\t");
break;
case 6: end_of_line=2;
printf("\t\t\t\t\t");
break;
case 7: end_of_line=1;
printf("\t\t\t\t\t\t");
}
for(i=1; i<=days_in_month; i++)
{
printf("%i\t",i);
if(end_of_line==1)
{
printf("\n");
end_of_line=7;
}
else
end_of_line = end_of_line-1;
}
printf("\n\nDo you want to continue? (Y/N): ");
scanf("%c", &dummy);scanf("%c", &dummy);
if(dummy == 'n' || dummy =='N')
break;
}
printf("\nProgramming Ended. Press Enter key to exit.....\n");
scanf("%c", &dummy);scanf("%c", &dummy);
}
hai
C:\Program Files\Microsoft Visual Studio\MyProjects\haihow\haihow.cpp(13) : error C2065: 'a' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\haihow\haihow.cpp(13) : error C2228: left of '.year' must have class/struct/union type
C:\Program Files\Microsoft Visual Studio\MyProjects\haihow\haihow.cpp(15) : error C2228: left of '.month' must have class/struct/union type
C:\Program Files\Microsoft Visual Studio\MyProjects\haihow\haihow.cpp(16) : error C2228: left of '.starting_day' must have class/struct/union type
C:\Program Files\Microsoft Visual Studio\MyProjects\haihow\haihow.cpp(17) : error C2228: left of '.starting_day' must have class/struct/union type
C:\Program Files\Microsoft Visual Studio\MyProjects\haihow\haihow.cpp(21) : error C2228: left of '.starting_day' must have class/struct/union type
C:\Program Files\Microsoft Visual Studio\MyProjects\haihow\haihow.cpp(60) : warning C4508: 'main' : function should return a value; 'void' return type assumed