1. ## help with functions??

We just started learning functions in my c programming class. We havent learned hardly anything about them yet, but we already have an assignment. It is a random number generator with a few things added in that our professor wanted. I have a working version, BUT, he wants us to do this:
Your program must decompose the problem into functions. Specifically, you must
declare and use a function that accepts two integer arguments as input and returns a value
as output. All of your printing must be done in the main function. The input arguments
represent a user’s guess and the correct answer. The returned value must reflect one of
the three possible outcomes of comparing the guess to the correct answer. The outcomes
are “Too Low”, “Too High”, or “Correct”. I recommend representing those outcomes
using integer values of -1, 1, and 0, respectively.

heres what i have...how do i do what he wants??

Code:
```#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(void)
{ /* begin function main */

int num; /* numbers generated */
int guess = 0;
int game = 0;
int counter = 0;

srand(time(NULL)); /* generate the random seed generator */
num =  rand() % 1000 +1 ;  /* pick a number from 1 to 1000 */

printf("I am thinking of a random number between 1 and 1000\n"); /* prompt user for input */
printf("Try and guess the number.\n"); /* prompt user for input */

do
{
while (num != guess)
{
scanf("%d", &guess); /* input data from user */
++counter;

if (guess > 1000 || guess <= 0)
{
printf("Number out of range\n");
printf("Try again\n");
}
else if (guess > num)
{
printf("Too High! try again!\n");
}
else if (guess < num)
{
printf("Too Low! try again!\n");
}
}  /*end while loop */

printf("You guessed the number in %d tries!\n",counter);
printf("Do you want to play again?\n");
printf("Enter  n or N to quit\n");
while ( getchar() != '\n' )
;
game = getchar();
getchar();
} /*end of do while */
while (game != 'n' && game != 'N');

return 0;

}/* end function main */```
thx

2. What is it about functions you don't understand? Do you know how to define one?

3. i figured it out, i didnt know how to define one first of all,but i understand now. our instructor made it sound like we had to create a function somewhere else and then call it up on our program. turns out i just had to define and create it at the top of the program. Bad instructions lol.