Saturday, June 22, 2013

TIC TAC TOE Game in C lanugage

TIC TAC TOE using C

Again a game, I developed it when I was in my BCA second year.
Compiler I used is Turbo C++ , I know its old one but I used only this.
It is a well known game.......
I have a bug in this game. I am unable to determine the error cause.
Its giving me an error -
"Graphics error : Not enough memory to load driver"

The game runs fine for sometime but after playing 3-4 chances it gives this error and terminates automatically. Try playing the game if you like it please share it or if you have any solution comment below.



Instructions before you run the code:



Set BGI Graphics path in initgraph() function according to your pc's Trubo C BGI library.
Here mine is c:\\turboc3\\bgi



If your compiler's graphic library is not included then you will find many errors in this program.
To avoid this follow the steps:
1. Go to compiler's option menu (ALT+O)
2. Then select Linker option
3. Then select Libraries option
4. Then Mark X to Graphics Library option using space button
5. Then select OK

All done.
If you want to save this changes permanently then do this:
1. Go to Option menu
2. Select Save then select OK



Screen Shots:





Code:

Here is the code of the game copy and paste and follow the instructions and run the game.
Works fine.

Program to find sum of digits of a number

Sunday, June 9, 2013

Program to convert binary number system to decimal number system

How to convert binary to decimal:

To convert any binary number to decimal follow these steps:
1. Take the LSB(Least Significant Bit) and multiply it with 20.
2. Now take next bit and multiply it with 21.
3. Now take next bit and multiply it with 22.
4. Follow this multiplication of next bit and increasing power of 2 until we reach MSB(Most Significant Bit).
5. Now add all the results of the steps above.

We will have the decimal equivalent.

Example:
Here I am converting binary number 1010 to its decimal equivalent.
(1010)2=(?)10

1.     0*20=0
2.     1*21=2
3.     0*22=0
4.     1*23=8
5.     0+2+0+8=10
so binary equivalent of 1010 is 10.

(1010)2=(10)10

This program will calculate binary to decimal for you:

Program to get Armstrong numbers between 1 and 1000

Armstrong number :
An Armstrong number is a number such that sum of cubes of its digits is equal to the number.
For example: 153 is Armstrong number because
13+53+33=153
370, 371 are also Armstrong numbers.

Here is the program code to find Armstrong numbers between 1 and 1000

Powered by Blogger.