Hi! I'm really new to C++ and posting to forums so please excuse any mistakes I may make.
I have to write a program that simulates throwing 2 die and printing their sum 25 times, seven sums per line. I'm stuck on the "seven sums per line." Do I need to do a separate loop for this? When I try to add something it causes an error to the srand.
This is how I started it:
#include <iostream>
#include <time.h>
using namespace std ;
int main()
{
srand(time(0)) ;
int count = 0 ;
const int NUMBER_OF_SUMS_PER_LINE = 7 ;
for (count = 0; count < 25; ++count)
{
int die1 = rand() % 7 ;
int die2 = rand() % 7 ;
int answer = die1 + die2 ;
cout << die1 << " + " << die2 << " = " << answer << ", " ;
}
return 0 ;
}
Thank you in advance!!