This question has already been answered:
unsigned f; cin >> f; do { if (f == 9) { srand(time(NULL)); for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { arr[i][j] = -100 + rand() % 200; } } } if (f == 0) { for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { cout << "Fill arr[" << i << "][" << j << "]: "; cin >> arr[i][j]; } } } if ((f != 9) && (f != 0)) { cout << "Error! Try again: "; cin >> f; } } while ((f != 9) && (f != 0)); 
