[C] Hallowe'en Candy
I can output a rounded up figure and I include user input validation. But what else am I missing here? #include <stdio.h> #include <math.h> /* function declaration */ double calculate(double); int main() { double houses; // variable double percent; do { // prompt user for input scanf("%lf", &houses); } while (houses < 3); // continue prompting if input is < 3 percent = calculate(houses); // assign variable to function value printf("%.0lf\n", round(percent)); // print value and round it } /* function for calculation */ double calculate(double input) { double result; double dollar = 2.0; result = dollar / input; result = result * 100.0; return result; }