Changing code syntax

I have this small program that simulates dice rolls using random numbers. It does 1 million rolls and outputs the results for 1, 10, 100....., 1000000. The way my code is structured right, the program starts by outputting the results for 1 roll, then does 9 other rolls and outputs the results again. I would like to make it so all the rolls are done before outputting anything, because right now I'm basically stopping every loop to check if a condition is met or not and I believe this is somewhat unrecommended. How could I make it so the output code is outside the random loop ?

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
int Nb;		
int Face;		
loat Fq1 = 0;	
float Fq2 = 0;	
float Fq3 = 0;	
float Fq4 = 0;	
float Fq5 = 0;	
float Fq6 = 0;	
int Mod;

	
srand((unsigned int)time(NULL));

for(Nb = 1; Nb >= 1 && Nb <= 1000000; Nb++)
{
	// Randomizing numbers
	Face = rand() % 6 + 1;

	switch(Face)
	{
		case 1: Fq1++;
			break;

		case 2: Fq2++;
			break;

		case 3: Fq3++;
			break;

		case 4: Fq4++;
			break;

		case 5: Fq5++;
			break;

		case 6: Fq6++;
			break;
	}


	// Averages
	float Pour1 = Fq1 * 100 / Nb;				
	float Pour2 = Fq2 * 100 / Nb;			
	float Pour3 = Fq3 * 100 / Nb;	
	float Pour4 = Fq4 * 100 / Nb;	
	float Pour5 = Fq5 * 100 / Nb;	
	float Pour6 = Fq6 * 100 / Nb;	
		


	// Output
        Mod = 1;
	if(Nb % Mod == 0)
	{
		gotoxy(0,1);
		cout << "Essaie avec " << Nb << " lancer(s):";
		cout << endl << endl;
		cout << setw(L1) << right << "Face";
		cout << setw(L2) << right << "Fr\x82quence";
		cout << setw(L3) << right << "Pourcentage";
		cout << endl;
		cout << setw(L1) << right << "1";
		cout << fixed << setprecision(0) << setw(L2) << right << Fq1;	
		cout << fixed << setprecision(2) << setw(L3) << right << Pour1 << "%";	
		cout << endl;
		cout << setw(L1) << right << "2";	
		cout << fixed << setprecision(0) << setw(L2) << right << Fq2;											
		cout << fixed << setprecision(2) << setw(L3) << right << Pour2 << "%";
		cout << endl;
		cout << setw(L1) << right << "3";
		cout << fixed << setprecision(0) << setw(L2) << right << Fq3;
		cout << fixed << setprecision(2) << setw(L3) << right << Pour3 << "%";	
		cout << endl;
		cout << setw(L1) << right << "4";	
		cout << fixed << setprecision(0) << setw(L2) << right << Fq4;	
		cout << fixed << setprecision(2) << setw(L3) << right << Pour4 << "%";	
		cout << endl;
		cout << setw(L1) << right << "5";
		cout << fixed << setprecision(0) << setw(L2) << right << Fq5;	
		cout << fixed << setprecision(2) << setw(L3) << right << Pour5 << "%";	
		cout << endl;
		cout << setw(L1) << right << "6";							
		cout << fixed << setprecision(0) << setw(L2) << right << Fq6;	
		cout << fixed << setprecision(2) << setw(L3) << right << Pour6 << "%";	
		cout << endl << endl;
        }
}
If you don't want your output code inside the loop, then you just put it outside.XD
The whole would like this:
Start with a for-loop doing 1000000 rolls. After it is done, take average and output.
I might be overcomplicating things here in my head, but I just don't see how I could easily make the program output the results for 1, 10, 100, etc.. up to 1 million.

The differents output screens are to be always at the same position, making the illusion the numbers are adding up (with a _getch() in between).

I'll try to think in a more simple way.
I just don't see how I could easily make the program output the results for 1, 10, 100, etc.. up to 1 million.
How about this:
1
2
3
4
5
6
7
8
        //Mod = 1; // do this before the start of the for loop instead

        if (Nb % Mod == 0)
        {
            Mod *= 10;
            gotoxy(1,1);
            cout << "Essaie avec " << Nb << " lancer(s):";
            // etc. 
Topic archived. No new replies allowed.