Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help on figuring why my code won\'t generate an output in eclipse it is a

ID: 3889043 • Letter: I

Question

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<stdio.h>
#include<math.h>
#include<stdlib.h>
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");

}

Explanation / Answer

Yeah, I am familiar with eclipse , try to create a NEW C/C++ project and then click on Run , If it fails
then you need to provide Build path.

Are you using Eclipse for C/C++ or which version are you using ?
I mean Juno/Kepler/mars etc ?

1. CREATE new project on eclipse
2. Then click on Run using that Project
3. At console you will get the Output

If not let me know if there is any problem , I will help and make it work.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote