I am new to using C++, just started learning a little while ago. So, what I've been trying to do[I didnt think it would be to difficult], was to have the computer randomly choose one of the questions I have set up, and then depending on what question was chosen, store the answer in the create variable. So far, this is what i have.
Code:
#include <string>
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
string name,birthday,favColor,country,petName,birthPlace,favBand, SendTo;
int age, favNumber, IQ, selected, i;
string question[10] [10];
question[0][0] = "What is your name?";;
question[1][0] = "When is your birthday?";
question[2][0] = "What is your favourite color?";
question[3][0] = "What country do you live in?";
question[4][0] = "How old are you?";
question[5][0] = "What is your favourite number?";
question[6][0] = "How many friends do you have?";
question[7][0] = "Do you have any pets?";
question[8][0] = "Where were you born?";
question[9][0] = "What is your I.Q?";
question[10][0] = "What is your favourite band?";
if (i < 10)
{
selected = (rand() % (10-1+1))+1;
switch(selected)
{
case 0:SendTo = name;
case 1:SendTo = birthday;
case 2:SendTo = favColor;
case 3:SendTo = country;
case 4:SendTo = age;
case 5:SendTo = favNumber;
}
cout << question[selected][0];
cin >> SendTo;
}
return 0;
}
A few notes:
1) I wasnt entirely sure on how to make a random number, so I googled it...and I dont know how that works exactly.
2) Also, the problem is that this code is NOT displaying anything. It will run, but, its not displaying anything.
3) Not sure if its important[I dont think it is], but im using Quincy 2005 to write this.