i had to make a program to print a calendar taking the input of number of days and the first day of the month from the user .
the sample output given in the question had no 0's and instead had blank spaces.
how do i remove the 0's from the unassigned positions in my calendar
#include <iostream>
usingnamespace std;
int calendar[6][7] ;
void cal(int y , int z) // y is number of days and z is the number corresponding
{ // to the first day
int n = 1 ;
for(int j=z-1;j<7;j++)
{
calendar[0][j] = n ;
n++ ;
}
for(int i=1;i<6&&n<=y;i++)
{
for(int k=0;k<7&&n<=y;k++)
{
calendar[i][k] = n ;
n++ ;
}
}
}
int main()
{ int d ;
int day ;
cout << "Enter number of days : " ;
cin>> d ;
cout<< "Enter first day of the month(1 for monday 7 for sunday..) : " ;
cin>> day ; cout<<"\n" ;
cal(d,day) ;
cout<<"M T W T F S S"<< endl;
cout<<"\n" ;
for(int i=0 ;i<6 ;i++)
{
for(int j=0 ;j<7;j++)
{
cout<<calendar[i][j]<<"\t" ;
}
cout<<""<< endl ;
}
}