I want to ask how can I print the word Chessmaster in 2d array randomly each letter of the word? I tried with srand but I don't how to combine it with characters. Can someone help me with is code. Also, can I create random letters in a 2d array without rand ?
#include <iostream>
#include <stdlib.h>
#include <time.h>
const int MAX = 11;
using namespace std;
void printwo()
{
char word[MAX] = {'c', 'h', 'e', 's', 's', 'm', 'a', 's', 't', 'e', 'r'};
int c, i, n, letters;
cout << "I will print this word " << word << " sepereate" << endl;
srand(time(NULL));
for (int i = 0; i < 7; i++)
{
for (int j = 0; j < 2; j++)
{
cout << "Print a random letter["
<< "][" << word[i] << "]"
<< "["
<< "]";
cout << endl;
}
}
}
int main()
{
int c;
cout << "Hello user press _1_ to continue" << endl;
cin >> c;
if (c == 1)
{
printwo();
}
else
{
cout << "Bye";
exit(0);
}
return 0;
}