Question 1a #include #include #include using namespace std; int main() { int r, i; srand(time(NULL)); for(i=0;i<10;i++){ r=rand()%5*2+1; cout << r << "\t"; } cout << endl; return 0; } Question 1b #include #include #include using namespace std; int main(){ int r, i; srand(time(NULL)); for(i=0;i<100;i++){ if(i%10==0) printf("\n"); r=rand()%90+10; printf("%d\t",r); } printf("\n"); return 0; } Question 2 #include #include #include using namespace std; int main() { int r, i; srand(time(NULL)); for(i=0;i<100;i++){ if(i%10==0) cout << endl; r=rand()%90+10; cout << r << "\t"; } cout << endl; return 0; } Question 3 #include #include #include using namespace std; int main() { int balance=100, invest, guess, d1, d2, d3, outcome; cout << "Let's start to play the game with 3 dices" << endl; cout << "Your balance = " << balance << endl; do{ do{ cout << "How much do you invest? "; cin >> invest; }while(invest>balance); do{ cout << "What is your expected outcome, big (1) or small (0)? "; cin >> guess; }while(guess!=0&&guess!=1); d1=rand()%6+1; d2=rand()%6+1; d3=rand()%6+1; cout << "The points of the 3 dices are " << d1 << "," << d2 << "," << d3 << "." << endl; if((d1+d2+d3)>10){ outcome=1; cout << "It is big, "; } else{ outcome=0; cout << "It is small, "; } if(guess==outcome){ cout << "a correct guess" << endl; balance = balance + invest; } else{ cout << "an incorrect guess" << endl; balance = balance - invest; } cout << "Your balance = " << balance << endl; }while(balance>0); return 0; }