Die rolller game assistance

How do I add another Function and make this game loop I want to use a while loop
//Nicholas Crowe
// Die Roller
// Demonstrates generating random numbers

#include <iostream>
#include <cstdlib>
#include <ctime>


using namespace std;

int main()
{
using std::cout;
using std::cin;

cout << " Welcome to Die Roller\n"

srand(time(0)); // seed random number generator based on current time

int randomNumber = rand(); // generate random number

int die = (randomNumber % 6) + 1; // get a number between 1 and 6
cout << "You rolled a " << die << endl;

return 0;
}
i dont get it if you want to make the game loop just add a while 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
#include <iostream>
#include <cstdlib>
#include <ctime>

using namespace std;

int main()
{
using std::cout;
using std::cin;
char n;

cout << " Welcome to Die Roller\n";
cout << " Press Enter to roll again or press q then enter to exit\n";
srand(time(0)); // seed random number generator based on current time

int randomNumber; // generate random number
int die;

//right here
while(n != 'q')
{
      randomNumber = rand(); 
      die = (randomNumber%6+1); // get a number between 1 and 6
      cout << "You rolled a " << die << endl;    
      n = getchar();
}

getchar();
return 0;
}
Topic archived. No new replies allowed.