Using a function to find the average for number of letters and words This is my code:

#include &lt;stdio.h&gt;
#include &lt;ctype.h&gt;
int average_of_let_wor();
int main(void)
{
    double answer;
    answer = average_of_let_wor();


    printf("%.2lf", answer);
    return 0;
}

int average_of_let_wor()

{
    double numberOfLetters = 0;
    double numberOfWords = 0;
    int userInput;
    double answer;
    printf("please enter your input:\n");
    while ((userInput = getchar()) != EOF)
    {

        if (userInput == ' ' || userInput == '\t' || userInput == '\n')
        {
            numberOfWords++;
            continue;
        }

        else
           numberOfLetters++;

    }
    answer = numberOfLetters/numberOfWords;
    return answer;
}
First of all, be careful with types: to compute an average something, you will need a floating point number. However, the number of letters and words are countable and can therefore use the type unsigned int which are generally faster than floating point numbers.

Moreover, to detect a "space" character, you can use the standard function isspace from the header ctype.h.

Also, the variable answer is useless. You can get rid of it and simply return the answer the same line you're computing it.

Therefore, your function average_of_let_wor can be reduced to:

double average_of_let_wor()
{
    unsigned int numberOfLetters = 0;
    unsigned int numberOfWords = 0;
    int userInput;

    printf("please enter your input:\n");
    while ((userInput = getchar()) != EOF)
    {
        if (isspace(userInput))
        {
            numberOfWords++;
        }
        else
        {
            numberOfLetters++;
        }
    }

    return (double)numberOfLetters / (double)numberOfWords;
}