#include <iostream>
#include <string>
usingnamespace std;
char randn(char letters) //random definition
{
return rand()%letters;
}
int main()
{
cout << "Welcome I am the magic 8 ball, because Adam writes basic programs."
<< endl;
cout << "Enter your question and I will answer it to the best of my poor abilities (Yes or no questions only)"
<< endl;
string question;
cin >> question;
string PossibleAnswers = "no", "yes", "maybe";
cout << rand(PossibleAnswers);
return 0;
}
(Note: I know I shouldn't be using namespace std as it is bad practice but only
I am using it on my test progs for shorter syntax)
Hey guys Im brand new to c++ been learning for about 3 weeks now. What I am trying to do is build a magic 8 ball that quips back random predictions of the future if you ask it a questions like "Will I win my march madness bracket?"
Anyway, I am trying to create a random out put to terminal. Not sure if I should be using cout or printf etc.
I know my code is off, probably should be using an array in some way. Help would be greatly appreciated!