Thread: question on homework

  1. #1
    Registered User camel-man's Avatar
    Join Date
    Jan 2011
    Location
    Under the moon
    Posts
    693

    question on homework

    I am creating a game and it askes the user to guess a number from 1 and 100 and to get it right.

    I am not sure how to address the actual random number, for example when the user guesses I will tell them whether or not it was too low or too high but I dont know how to address the actual random number


    Code:
    #include <time.h>
    #include <stdio.h>
    #include <stdlib.h>
    
    #define MAX 100
    
    int main()
    {
     	
    	int guess=0, numGames=0, done=0
    	float avg=0;
    
    
    	srand( (int) time(NULL));
    
    	 printf("you are guessing a number between 1 and 100\n");
    
    	printf("type in your number\n");
    	scanf("%d", &guess);
    
    	
    
    
        
        
    
        return 0;
    }
    Last edited by Salem; 02-02-2011 at 01:24 PM. Reason: Added [code][/code] tags - learn how to do it now!

  2. #2
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    You should really put your source code in [ code ] tags, it makes it far more readable.

    But how to get a random number... Use the rand() function.

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    The FAQ, heard of it?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question About My Homework Pls Help Me İmmediately
    By jennyyyy in forum C Programming
    Replies: 27
    Last Post: 03-13-2008, 11:40 AM
  2. quick question
    By surfingbum18 in forum C Programming
    Replies: 5
    Last Post: 12-04-2007, 06:16 AM
  3. Design layer question
    By mdoland in forum C# Programming
    Replies: 0
    Last Post: 10-19-2007, 04:22 AM
  4. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM
  5. Very simple question, problem in my Code.
    By Vber in forum C Programming
    Replies: 7
    Last Post: 11-16-2002, 03:57 PM