Name: [3253] gasto
Member: 83 months
Authored: 41 videos
Description: C/C++ and python programmer. Some knowledge of graphic design too. Interested in Game Artificial Intelligence and Artificial Life. Currently studying(by myself)too many things to be worth the mention. Happy to contribute to the 'help-without-compensation-asked' community. I hope every one that r ...

C tutorial - Number guessing game - [ID:681] (8/8)

in series: C programming tutorial.

video tutorial by gasto, added 04/08

Series ID: 138 Video ID: 681

We start programming more serious programs, knowing more about standard function calls, keyboard shortcuts, modulus operator, the general planning and design of a program, loops, and the continue and break keywords used in loops. We finish the program without any errors. What about making your own program following the same design, but adding some statments, to add features, for example: print on console how many times did it took the user to guess the number; print compliments to users depending on how much attempts did it take, or how much time passed since the beginning of running the program, or both. Remember all this videos are in vain if you do not put in practice the theory you have just learnt.

Take your rehearsal test

Visit the C Console Programming video series for updates on C programming from me.

// numguess.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{
	int unsigned answer_num, guess_num;
	srand((unsigned)time(NULL));
	answer_num = (rand()%11);
	printf("Guess a number from zero to ten : " );
	while (1){
			scanf("%i", &guess_num);
			if (guess_num>=0 || guess_num<11){
				if (guess_num<answer_num){
				printf("Try a higher number! ");
				continue;
				}
				else if (guess_num>answer_num){
				printf("Try a lower number! ");
				continue;
				}
				else if (guess_num==answer_num){
					printf("You are the champion!, the number "
					"guessed was %d!", answer_num);
					break;
				}
			}
			else{
				printf("assert that the number inserted is between 0 and 10");
				continue;
			}
	}
	//time_t * tim;
	//time(tim);
	//printf("%d", *tim);
	fflush(stdin);
	getchar();
	return 0;
}

Got any questions?

Get answers in the ShowMeDo Learners Google Group.

Video statistics:

  • Video's rank shown in the most popular listing
  • Video plays: 3210 (since July 30th)
  • Plays in last week: 0
  • Published: 78 months ago

Thank-yous, questions and comments

If this video tutorial was helpful please take some time to say thank-you to the authors for their hard work. Feel free to ask questions. Let the author know why their video tutorial was useful - what are you learning about? Did the video tutorial save you time? Would you like to see more?

You may also want to see our ShowMeDo Google Group to speak to our active users and authors.

Your email address will not be published.

Show some quick comments >>








All comments excluding tick-boxed quick-comments

Your video has been edited. This is an automatic post by ShowMeDo.


Unfortunately I have no terminal with Unix, although some Ubuntu(Linux) GCC tutorials could turn out a good idea.


5. Tatiana Agupova Fri, 19 Mar 2010 05:43

Awesome video. Thank you!

Can you do some system calls programming for Unix?


4. joe oettinger Sun, 28 Feb 2010 11:33

Nice tutorial. I guess it's intended for beginners, but it's a good review too.

Thanks!

Joe


I request you to send me the same "number guessing program" code usins Unix using semaphores, multithreading concepts


2. anonymous Mon, 12 Oct 2009 17:39

I have enjoyed your all eight tutorial. excellent. Watching it helpful.

please be keep posting any more! Thank you very much. Bye Bye.


thank you very much

keep up a good work :)


Showmedo is a peer-produced video-tutorials and screencasts site for free and open-source software (FOSS)- with the exception of some club videos, the large majority are free to watch and download.

how to help » about » faq »

Educating the Open-source Community With Showmedo

Although as important as the software it supports, education and documentation are relatively neglected in the Open-source world. Coders love to code, and explaining how best to use or improve the software tends to be deferred or even sidelined.

At Showmedo we believe the community can play a vital role here and also say thanks for the tools and software that make our lives easier. If you have a piece of software you love or a programming langugage you are enthusiastic about, why not make a screencast showing others how to use it? All the stuff you wish you'd been told, the tips, tricks, insights that would have saved you time and frustration.

Screencasting is easier than you think, and we're happy to help you. You can emailus for advice or just use some of the how-to screencasts on the site. This screencasting learning-pathis a good place to start.

Kudos and Thanks for gasto

Content

Feedback

Showmedo's development is fairly rapid and bugs will inevitably creep in. If you have any problems please drop us a line using the contact address below. Likewise, any suggestions for improvements to the site are gratefully received.

feedback@showmedo.com