First game using c language


Published on

  • Hello Ananya firstly i am sorry for the late reply was busy with my work , read your comment today. The reason you are unable to include files in your compiler is because it must not have the prototype declaration included, try & re install your compiler i believe it will be done. For any further assistance Contact me at :
    Are you sure you want to  Yes  No
    Your message goes here
  • I have an issue. I copy pasted the program exactly into my compiler (Turbo C) but it shows the errors 'Unable to open include file 'STDAFX.H' ', 'Unable to open include file 'WINDOWS.H', & 'function 'GetTickCount' should have a prototype'. Why is that?
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

First game using c language

  2. 2.  Hey guys, how are you all. I hope you all remember me, and might have seen my work in past. My name is Saurabh khetan. Its been long time I haven‟t uploaded anything. The reason is I was trying to come to you all with something interesting.
  3. 3.  To learn from basic is always a better idea rather than jumping to something really advanced. Starting to learn from the basics leads a learner to hit the „bulls eye‟.
  4. 4.  So for getting things in much easier way we need to learn a lot about the language in which we are developing our first game. As I have mentioned earlier the viewers interested in developing anything whether it is simple or complex. They need to develop their logical reasoning first. This is the only thing through which we would be able to conclude what are the parameters we need to work on.
  5. 5.  The first and the foremost thing is to give a microscopic view at the „C‟ Language. If a software engineer is not comfortable with this language, then his journey would end like any paper made ship in the rain water. But no, we will create something far excellent than everyone‟s imagination.
  6. 6.  Just read everything very carefully in this language, and we make wonders happen. Now done with lots of philosophy and is the time to get back to the things. So for now its just a simple game I have developed using this language. The game is a simple guessing game, wherein the player has to guess the number the computer is thinking at that point of time.
  7. 7.  The time you will look at the game you will get to know something that is not going according to you or the way it should have happened. But after reading the above sentence don‟t get panic that you won‟t understand anything but make sure that you have just read and typed the program correctly. The exactly written program will maintain the balance of the working of the game. Since my first upload I have been emphasizing on writing the program in the editor instead of just pasting it.
  8. 8.  The specialty of this program is that it does not contain anything so much serious that a fresher is unable to understand. To understand this one is not any kind of rocket science we are trying to learn. All such things should not come to our mind when we need to progress. I have used certain functions and few things which might not be familiar to you, so make sure that you go behind them to get to know about them.
  9. 9.  Yeah one more thing before I present you my first developed game using „C‟ Language. This game also contains the working of „loop‟ instructions most often used instructions in the language programming. The loop in its simple meaning means a code which is running until it is allowed to run. This is the most simple explanation about this instruction I can provide to you at such a short notice. If you want any more knowledge about this instruction send me an email I will develop a presentation for you.
  10. 10. PROGRAM ! ! ! !THE MOST AWAITED THING !!!!!!!!!!!!!!!!!
  11. 11. PROGRAM:-#include"stdafx.h"#include<stdio.h>#include<windows.h>#include<stdlib.h>int main(){int RandomNumber,Theusersguess,Numberofguesses=0;srand( GetTickCount() );RandomNumber=(rand()&31)+1;printf("This is a simple guessing game where you have to guess the numbernn");printf("i am thinking about right now in my mind,the number may exist from 1 to 32nn");printf("You have to guess the exact numbernnyou will also get to know in how many chances you have guessed itnn");printf("As soon as you hit the exact numbernnyou will get to know how good mind reader you are?????nn");do{printf("enter a number from 1 to 32 ");scanf("%d",&Theusersguess);Numberofguesses++;if(Theusersguess>RandomNumber)printf("The number you guessed is greater than what i am thinking ");if(Theusersguess<RandomNumber)printf("The number you guessed is lower than what i am thinking ");}while(RandomNumber!=Theusersguess);printf("Congratulations you have got the number and the BMW is yoursn");printf("You have guessed it in %d chances ",Numberofguesses);}
  13. 13.  The program presented to you is the exact one I have developed through this language. Just make sure you have understood this one fully and correctly and also with no doubts in your mind. Now I got to tell you something about this program, there are some functions I have used in it. The functions srand( ), GetTickCount( ), rand( ) are all new to you and are also case sensitive, they need to be written correctly.
  14. 14.  All this functions are the one which generates the random number between the range we have decided. The random numbers are generated every time you wish to run the program for the new player. As you can observe in the program I have used a lot of text to make it more clear and obvious for a player to understand the plan behind it, what actually I want him to do. This text format can be changed according to your convenience. Instead of the “BMW” you can present them any other thing………………..! ! ! !
  15. 15.  The two text written outside the “do-while loop” instruction syntax will get printed at the time you have guessed the number that is randomly generated. The bluff I have played is that I have written in this program you have to guess the number I am thinking but its the computer or more probably the compiler which generates it. But its nothing to worry we are just trying to make it more fascinating for the players. Its what every developer do………. ! ! ! !
  16. 16.  As soon as you type the number that is randomly generated and enter it you will get a winning message. The messages within the “do-while loop” are for the users to reach the number, they will let you know if the number is smaller than the generated one or greater than it. Using the help of all this messages you will able to guess the exact number. You may enter the prizes that will be offered to the players if guess the number in a single chance or in second chance.
  17. 17.  Number of chances required I also printed after the completion of the game. So guys, I have tried a lot to hit the nail and I think I have done it well according to my very poor knowledge. Now its up to you all to provide me with your feedbacks to let me know about my work. The areas where I need to improve and to work more efficiently, whether it is regarding my presentation or anything that you feel.
  18. 18.  Its always good to know about our work. It lets us know where do we stand and the parameters we need to work on. Any help regarding this program or my previous ones or any query regarding them will be resolved. Just mail me your problem at One more thing before I end up my presentation, do download and see this one it will help you in lot many ways.
  19. 19.  If you liked this presentation and you think that I am that much capable to do anything for you and could do justice to you, you are free to ask me to prepare any kind of presentation on any topic related to „C‟ Language. Your feedbacks helps us to take care of things that makes it easy for you to understand.