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)