Return to site

How To Write A Blackjack Program In C

broken image


20 Dec 2010
  1. How To Write A Blackjack Program In Computer
  2. How To Write A Blackjack Program In Construction
  3. How To Write A Blackjack Program In C Programming

Now I'd like to share one of my experience of programming C.

. Write a program that plays Blackjack. Have the program use at least 3 functions: 1. For the Dealer 2. For the Player 3. To deal a card. Have the program intelligently determine if an Ace should be interpreted as a 1 or an 11. This is somewhat difficult. You need to be able to also handle multiple aces. C/C:: Program That Scores Blackjack Hand? Write a program that scores a blackjack hand. In blackjack, a player receives from two to five cards. The cards 2 through 10 are scored as 2 through 10 points each. The face cards - jack, queen, and king are scored as 10 points. To start the game of Blackjack, players are dealt two cards at random from a shuffled deck. You write the following code to simulate the act of dealing an initial hand. To test the code, you deal a hand 1 0 6 10^6 1 0 6 times and record the number of times the player. This is my first real program, though it has gone through a few major revisions. Anyhow, I am sure that there is a lot I could have done better, cleaner or safer. Can anyone see anything I really. Write a program that scores a blackjack hand. In blackjack, a player receives from two to five cards. (The player decides how many, but that has no effect on this exercise.) The cards 2 through 10 are scored as 2 through 10 points each. The face cards, jack, queen, and king are scored as 10 points.

Our teacher gave us a task: to finish a small but not so useless program by our own in C. He gave three options and unluckily, I was so confident that I chose the most difficult one: to write a program of Blackjack (simplified though, without money involved), also known as Twenty-one, played in command line.

It is a disaster. Though I scanned lots of programming books, however, I haven't really finished a useful project before. In this task, I strongly realize how stupid I am.

First of all, I don't know the way to shuffle the 52 cards. Their order requires random, no repeat, and easy to access. 'Array', you must say. However, I didn't exactly understand how it works in C, and I had to find out the algorithm, which our teacher didn't tell us. And after I found the answer to the algorithm, I was trapped in the pointers and arrays, and my poor understanding to function in C forced me to face strange warnings and errors. I wasted long long time to debug the shuffle_cards() function, though in the end I realized how simple it is.

Secondly, too many branches in the game exactly annoyed me a lot. There are too many possible results of the game, due to its rules. So I had to use lots of if(){}else{} statement, which results in ugly look and slow performance.

How To Write A Blackjack Program In Computer

Finally, problems occur when I want to compile the code. I develop it in Ubuntu Linux, and gcc works fine. But it seems that Visual C++ 6.0 doesn't like the code! Luckily I found alternative compiler in Windows: Dev C++ and Tiny C Compiler. And I finished it now. They are ugly and unclean codes. :-(

It is an unforgettable experience. Well, anyway, after all, I dare to say I have developed in C now!

I have uploaded it to https://github.com/fyears/simple-Black-Jack now.

How to write a blackjack program in c++

How To Write A Blackjack Program In Construction

Related Posts

How To Write A Blackjack Program In C Programming

Please enable JavaScript to view the comments powered by Disqus.




broken image