How do you loop numbers around for calendar?


I have been working on this program for hours and cannot find out how to make the numbers loop around after they hit saturday. They either go way passed it to the right or if i add and endl; they go up and down.

// This is how my output looks like (except they curve around they just go forever to the right:

Number of days: 31
Offset: 0
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31


// This is my program, what do i need to add? please help

#include <iostream>
#include <iomanip>
using namespace std;


/*************************************************
* Prompt for days
**********************************************/
int GetDays()
{
int days;
cout << "Number of days: ";
cin >> days;
return days;
}

/***************************************************
* compute offset
***************************************************/
int ComputeOffSet()
{
int num = 0;
cout << "Offset: ";
cin >> num;
return num;
}

/***************************************************8
* add display
*****************************************************/
void display(int days, int num)
{
cout << " Su Mo Tu We Th Fr Sa" << endl;


num = num * 3 + 3;
for (int s = 0; s < num; s++)
{
cout << " ";
}

for (int i = 1; i <= days; i++)
{
num += i;

cout << setw(4) << i;
}

cout << endl;

}
/**********************************************************************
* Add text here to describe what the function "main" does. Also don't forget
* to fill this out with meaningful text or YOU WILL LOSE POINTS.
***********************************************************************/
int main()
{
int days = GetDays();
int num = ComputeOffSet();
display(days, num);
return 0;
}
closed account (48T7M4Gy)
Don't post twice for same problem
Topic archived. No new replies allowed.