/*********************************************************** game.ch Introduction to Ch This program introduces the rand() function to generate a random number. We need to include new libraries, specifically stdlib.h and time.h. ************************************************************ Copyright 2014 SoftIntegration Inc. http://www.softintegration.com Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 ***********************************************************/ // initialize variables int guess, x; // ask user for input printf("I'm thinking of a number between 10 and 25. Guess my number: "); scanf("%d", &guess); x = randint(10, 25); // generate a random number between 10 and 25 // while the user's guess is wrong, run while loop while (guess != x) { printf("Try again: "); scanf("%d", &guess); } printf("You got it! My number is %d\n", x);