Help with number guessing game

This is a discussion on Help with number guessing game within the C Programming forums, part of the General Programming Boards category; I am having trouble with this lab. This lab needs to consist of a do while statement and the functions ...

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    1

    Help with number guessing game

    I am having trouble with this lab. This lab needs to consist of a do while statement and the functions need to be compiled and tested with at least 5 values. I can compile it and test it but the code is the problem.

    The directions of this lab is:
    http://astro.temple.edu/~rl/Lab%20Assignment%204.pdf

    So far I have:

    Code:
    // Include standard header files
    #include <stdio.h>
    #include <stdlib.h>
            
    // Create symbolic constants
    #define ERROR_DIFFERENCE 0.00001
    #define MAXIMUM_TRIES 100 
    #define MOST_TRY_PROMPT "Enter the maximum number of iterations to perform"
    #define X_GUESS_PROMPT "Enter your initial guess for x:"
    #define GUESS_ERROR "Initial guess out of range. Halting calculation. Try another guess"
    #define PROGRAMMER_NAME "Dimple Gandhi"
            
    int getInitialGuess()
    void compute_and_report(int most_tries, double my_guess);
            
    int main()
    {       
            int most_tries; 
            double my_guess;
            most_tries = getMostTries( );
            my_guess = getInitialGuess( );
            compute_and_report( most_tries, my_guess );
            
            return EXIT_SUCCESS;
    }
            
    getTries()
    {
            int Tries
            printf( "%s.\n", MOST_TRY_PROMPT );
            scanf( "%d", most_tries );
            printf( "The number of tries is %d.\n\n" )
            return most_tries;
    }       
    
    double getInitialGuess()
    {
            double my_guess;
            printf( "Programmer: %s.\n", PROGRAMMER_NAME );
            printf( "%s.\n", X_GUESS_PROMPT );
            scanf( "%d", &my_guess);
            printf( "The number entered into \"my_guess\" is %d. \n\n", my_guess );
            
            return my_guess;
    }
            
            
    {
            int counter; /* interation counter */
            double my_guess; /* user entered value guess */
            double root_calculated; /* newly calculated value of X */
            double test_for_pos; /* quantity */
            double abs_diff; /* absolute difference between root and guess */
            int most_tries; /* maximum number of iterations we'll try to converge */
            
            test_for_pos = pow(10 - 3*my_guess,2)
            root_calculated = pow(test_for_pos,0.2)
    Last edited by iceangel393; 02-23-2011 at 05:08 PM.

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,166
    Code:
    getTries()
    {
            int Tries
            printf( "%s.\n", MOST_TRY_PROMPT );
            scanf( "%d", most_tries );
            printf( "The number of tries is %d.\n\n" )
            return most_tries;
    }
    Are you sure it compiles? And if it does, are you sure you're pasting the code you're compiling?
    If you understand what you're doing, you're not learning anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner in C first menu - need critique
    By jimtuv in forum C Programming
    Replies: 8
    Last Post: 05-18-2010, 11:58 AM
  2. [freefps]Tactical Assault coders needed
    By Sickmind in forum Projects and Job Recruitment
    Replies: 4
    Last Post: 05-07-2010, 05:06 PM
  3. 2D RPG Online Game Project. 30% Complete. To be released and marketed.
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 10-28-2006, 12:48 AM
  4. Random guessing game
    By Nalif in forum C Programming
    Replies: 16
    Last Post: 10-26-2006, 03:05 AM
  5. C Programming 2d Array Question
    By jeev2005 in forum C Programming
    Replies: 3
    Last Post: 04-26-2006, 03:18 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21