Calendar Program

I have been working on a calendar program and i cant get it to output propely any help would be really appreciated. i have been trying it for hours.

this is what i have done so far

#include "stdafx.h"
#include <iostream>
using namespace std;
#include <iomanip>



void output_month()
{
int i;
i=0;
int j;
cin>>j;


do
{
++i;
cout<<setw(3)<<i;
if(i>=7)
{
cout<<"\n";
}



}
while(i < j);


}




void main()
{
cout<<"Input an Integer";
cout<<endl;
output_month();//call


system("pause");
}



i need to adapt the program above by incorporating an if statement so that the output starts on a new line every 7th number

can anyone help? please.
It can be achieved using the modulo-operator. Do you know modulo from math? I can explain if not. Here is code:

1
2
3
4
5
6
for (int i = 0; i < 100; i++) {
    cout << i; // print number to screen.
    if (i % 7 == 0) { // this means that an integer 'n' exist so, that ' i = 7 * n + 0 '
        cout << endl;
    }
}


Maikel

Edit: I recommend you to use

1
2
3
4
5
int main()
{
    ...
    return 0;
}


instead of void.
Last edited on
Topic archived. No new replies allowed.