I'm writing a program that rolls a die a number of times that the user enters, and counts up each time a one, two, three, and so on is rolled. Right now, it only prints out zero's. Any guidance would be appreciated!
Here's my code:
// dice.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int one = 0;
int two = 0;
int three = 0;
int four = 0;
int five = 0;
int six = 0;
int result[6] = {0};
int numberOfRolls;
cout << "Enter the number of times that you want to roll the die: ";
cin >> numberOfRolls;
for (int counter= 1; counter < numberOfRolls; counter++)
{
int answer = result[rand() % 6 + 1];
if(answer == 1)
one++;
if(answer == 2)
two++;
if(answer == 3)
three++;
if(answer == 4)
four++;
if(answer == 5)
five++;
if(answer == 6)
six++;
}
cout << "The number of one's rolled is: " << one << endl;
cout << "The number of two's rolled is: " << two << endl;
cout << "The number of three's rolled is: " << three << endl;
cout << "The number of four's rolled is: " << four << endl;
cout << "The number of five's rolled is: " << five << endl;
cout << "The number of six's rolled is: " << six << endl;
system("pause");
return 0;
}