Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help on figuring why my code won't generate an output in eclipse it is a compiler I have to use. Is anyone familiar

I need help on figuring why my code won't generate an output in eclipse it is a compiler I have to use. Is anyone familiar with eclipse? I believe I already have the code completed.

#include #include #include void main() { //create array of cards from Ace to king char *cardValue[] = {"ace","two","three","four","five","six","seven","eight","nine","ten","joker","queen","king"}; //create array of suites char *cardSuite[] = {"clubs","diamonds","hearts","spades"};

//declare time variable to use in random as a seed time_t t; //this will use t as a seed, and will give the next random different everytime srand((unsigned) time(&t));

//computer will select a random card char *randomCardValue;

//computer will select a random suit char *randomSuite;

int suiteChoice=0,cardChoice=0; do { //generate random card randomCardValue = cardValue[rand() % 13]; //generate random suite randomSuite = cardSuite[rand() % 4];

//make these lines comment printf("%s ",randomCardValue); printf("%s ",randomSuite);

//for loop to display suites int i=0; for(i=0;i<4;i++) { printf(" %d. %s ",(i+1),cardSuite[i]); } //quit option printf("5. Quit the game"); printf(" Choose your suite, Enter corresponding value :"); //scan choice using scanf scanf("%d",&suiteChoice);

//quit the game if if(suiteChoice==5) break;

if(suiteChoice < 1 || suiteChoice > 5) { printf(" Invalid choice "); break; } //if suite matches if(strcmp(randomSuite,cardSuite[suiteChoice-1])==0) { //display 13 cards for(i=0;i<13;i++) { printf("%d. %s ",(i+1),cardValue[i]); } //display quit option printf("14. Quit the game"); printf(" Choose your card, Enter corresponding value :"); //enter choice using scanf scanf("%d",&cardChoice);

//quit game if if(cardChoice==14) break;

if(cardChoice < 1 || cardChoice > 14) { printf(" Invalid choice "); break; } //if card matches if(strcmp(randomCardValue,cardValue[cardChoice-1])==0) { //print Congratulations message printf(" Congratulations, you have won. "); } //you loose else { //print loosing message printf(" You loose"); //print selected suite printf(" Your selected suite = %s",cardSuite[suiteChoice-1]); //print random suite printf(" Random suite = %s",randomSuite); //print selected card printf(" Your selected card = %s",cardSuite[cardChoice-1]); //print random card printf(" Random Card = %s",randomCardValue);

break; } } //wrong suite selected else { printf(" You have selected wrong suite."); break; }

}while(cardChoice!=14 || suiteChoice!=5); //thanks and inviting message printf(" Thanks for playing, Try next time");

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Security

Authors: Alfred Basta, Melissa Zgola

1st Edition

1435453905, 978-1435453906

More Books

Students also viewed these Databases questions

Question

Explain what a patent is and describe different types of patents.

Answered: 1 week ago