I am attempting to assign two random integers to two arrays. I will leave the entire code here, but i left what is specifically in question at the top... I know that entering the entire code is needless and excessive, but im not sure if I made a mistake somewhere in the middle of the code that is contributing the the error in the for loop.
for (int i = 0; i < 2; i++) {
dc[i] = srand(time(0))%14;
pc[i] = srand(time(0))%14;
}
#include<iostream>
#include<string>
#include<cstdlib>
#include<ctime>
usingnamespace std;
double balance = 0;
double input = 0;
char a;
int main() {
cout << "Welcome to the Black Jack Table" << endl;
while (1) {
int dealer = 0;
int player = 0;
int pc[2] = { 0,0 };
int dc[2] = { 0,0 };
if (balance == 0) {
cout << "You currently have no balance, please enter cash now if you would like to play black jack" << endl;
cin >> input;
balance = input + balance;
cout << "Balance: " << balance << endl;
input = 0;
}
elseif (balance <= 0) {
cout << "Your balance is currently negative, please enter more cash or we will have to call security: " << endl;;
cout << "Balance: " << balance << endl;;
cin >> input;
balance = input + balance;
input = 0;
}
else{
system("CLS");
cout << "Balance: " << balance << endl;;
cout << "Enter (1) to play Black Jack, (2) to deposit more money, (3) to withdraw money from your balance, (q) to leave the table and withdraw all money" << endl;
cin >> a;
switch (a) {
case'2':{
cout << "Enter the amount you would like to deposit" << endl;
cin >> input;
balance = input + balance;
input = 0;
cout << "Balance: " << balance << endl;
}
case'3': {
cout << "Enter the amount you would like to withdraw" << endl;
cin >> input;
balance = balance - input;
input = 0;
cout << "Balance: " << balance << endl;
}
case'q': {
cout << "You leave here with a balance of : " << balance << endl;
balance = balance - balance;
break;
}
case'1': {
system("CLS");
for (int i = 0; i < 2; i++) {
dc[i] = srand(time(0))%14;
pc[i] = srand(time(0))%14;
}
}
}
}
}
}