Preview:
#include <stdio.h>

int main() {
    int num, sum = 0, count = 0;

    printf("Number (-1 to stop)? \n");
    while (1) {
        scanf("%d", &num);
        if (num == -1) {
            if (count == 0) {
                printf("No numbers input.\n");
                return 0;
            } else {
                break;
            }
        }
        sum += num;
        count++;
        printf("Number (-1 to stop)? \n");
    }

    int average = (int)sum / count;

    if (count == 1) {
        printf("\nThe average of the 1 number input is %d\n", average);
    } else {
        printf("\nThe average of the %d numbers input is %d\n", count, average);
    }

    return 0;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter