need to use the random number generator I am using in the code.
need it to display the results I have listed under void for the result of the coin toss.
and then need to make it ask if I want to flip again(which is not included yet).
Code:
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
using namespace std;
char AskForInput();
void DisplayHead();
void DisplayTail();
int result;
int main()
{
srand(static_cast<unsigned int>(time(0)));
int HeadOrTails = rand();
int result = (HeadOrTails % 2) + 1;
int Heads=1;
int Tails=2;
char AskForInput;
cout << "\n\nEnter your guess: ";
cin>> AskForInput;
cout<<"You guessed:"<<AskForInput;
cout<<"\nResult is:"<<result;
if (result=1)
{
cout<<"\nThe Result is Heads";
}
if (result=2)
{
cout<<"\nThe Result is Tails";
}
void DisplayHeads();
{
cout<<"\n _.-'~~`~~'-._ \n";
cout<<" .'` B E R `' \n";
cout<<" / I T |; \n";
cout<<" /` .-'~''-. ; \n";
cout<<" ; L / `- \ Y ; \n";
cout<<" ; /> `. -.| ; \n";
cout<<" | /_ '-.__) | \n";
cout<<" | |- _.' \ | | \n";
cout<<" ; `~~; \\\\ ; \n";
cout<<" ; INGODWE / \\\\)P ; \n";
cout<<" ( TRUST '.___.-'`'' / \n";
cout<<" `( /` \n";
cout<<" '._ 1 9 9 7 _.' \n";
cout<<" `'-..,,,..-'` \n";
}
void DisplayTails();
{
cout<<"\n _.-'~~`~~'-._ \n";
cout<<" .'`A R `' \n";
cout<<" / U __ T |; \n";
cout<<" /` /'{> ; \n";
cout<<" ; Q ____) (____ E ; \n";
cout<<" ; //'--; ;--')) R ; \n";
cout<<" | ///////[_])))))) | \n";
cout<<" | m m | \n";
cout<<" ; TAILS ; \n";
cout<<" ;D ; \n";
cout<<" ( R/ \n";
cout<<" '( O A/` \n";
cout<<" '._ L L _.' \n";
cout<<" `'-..,,,..-'` \n";
}
return 0;
}
my Question is:
How do I get it to take the result of the random number generated(the toss )
and use it in the coding to let it display a message.
"example"
Code:
if(result=AskForInput)
{
cout<<"You Guessed Correctly";
and then how do I let it display the "DisplayHeads" / "DisplayTails" after it checks for the result?