#include <iostream>
usingnamespace std;
int main(int argc, char *argv[]) {
int i,d;
cout<<"Enter Start Day : ";
cin>>d;
cout<<"\nSAT SUN MON TUE WED THU FRI\n";
for (i=1;i<=d;i++) {
if (d>1)
cout<<" ";
}
for (i=1;i<=90;i++) {
if(i<10)
cout<<i<<" ";
else
cout<<i<<" ";
if ((d-1+i)%7==0)
cout<<"\n";
if (i%30==0 && i<90) {
cout<<"\n\n";
cout<<"SAT SUN MON TUE WED THU FRI\n";
}
}
return 0;
}
everything is ok,1st month is currectly created,but the problem is on 2nd and 3rd month. i want to start new month from a day after previous Month ended with.
like This :
1 2 3 4 5 6
SAT SUN MON TUE WED THU FRI
27 28 29 30
**NEW MONTH**
SAT SUN MON TUE WED THU FRI
1
Use a variable to keep track of the last day of the month, then you will know that the next month will be the next day after it, you can use an enum class for that
enumclass days: int {MON=1,TUE,WED,THU,FRI,SAT,SUN};
If the last day of the month will be Sunday, then the first day of the next month will be Monday, otherwise it will be last day+1
Thanks, but i'm newbie in c++ and it's my homework exercise, and we only learn (if,for,int,float) and arrays. and i can't use enum class.
anyway with if and for.?
thanks.
Then just use numbers, enum class is more for convenience. If the last day of the month is 6(Sunday), then the first day of the next month is 0 (Monday), otherwise, it's gonna be last day+1.
You can use a bi-dimensional array for this or use another variable that increases every time you add a day and resets to 0 if it goes over 6 (because you start from 0). Just integrate it in your loop for days.
1 2 3
if(day_counter==6) // check if the last value is Sunday
day_counter=0; //then the next will be Monday
else ++day_counter; //otherwise increase it by 1