i'm having problems with dev c++, it wont let me assign a statement to a variable:
also, i'm trying to learn how to generate a random number, here's what i want to do, i want it to generate a number betaween 1 to 13!Code:nDCard1=rand()%13+1
here's the code i'm trying to do, could u pls see if it's correct? i havent tested it cuz it wont compile due to the error above
thanx a lot! i'm so glad i found this site! i'm a new member by the wayCode:#include <stdio.h> #include <stdlib.h> #include <time.h> int main(void) { int nMoney = 100, nBet, nDCard1 = 0, nDCard2 = 0, nDCArd3 = 0; int nSuit,nDCard4 = 0, nDCard5 = 0; char dev_c; srand(time(NULL)); printf ("Your money: $ %d\n", nMoney); printf ("Your bet: $ "); scanf ("%d\n", &nBet); printf (">>> Here are the dealer's cards <<<"); nDCard1=rand()%13+1 switch (nDCard1) { case 1: printf ("Ace of"); case 2: printf ("Two of"); case 3: printf ("Three of"); case 4: printf ("Four of"); case 5: printf ("Five of"); case 6: printf ("Six of"); case 7: printf ("Seven of"); case 8: printf ("Eight of"); case 9: printf ("Nine of"); case 10: printf ("Ten of"); case 11: printf ("Jack of"); case 12: printf ("Queen of"); case 13: printf ("King of"); } return(0); scanf ("%c", dev_c); scanf ("%c", dev_c); }



LinkBack URL
About LinkBacks


