[C] King exercise 6.1

From: Gary Schenk (gwschenk_at_fuzz.socal.rr.com)
Date: 03/31/04

Date: Wed, 31 Mar 2004 19:00:22 GMT

I am a lone student attempting to learn C. My only real experience
programming is from taking a Perl course from the local university
extended education course. I know no programmers and need some

I am reading C Programming: A Modern Approach. I'm finding it to be an
excellent book, far superior to my first C book "C for Dummies". I've
done all the exercises and think they are well thought out.

In chapter 6 things are getting more complicated and I'd like some
feedback from folks who know what they are doing.

Exercise 6.1 asks you to write a program which displays the largest
of a series of numbers entered by the user. The program must terminate
when the user enters a zero or negative number.

This seems to work, but I wonder is there a better way?

#include <stdio.h>

    float n, input;

    printf("\n\n\nFind a Big Number\n\n");
    printf("Enter a series of numbers or 0 to quit: ");
    scanf("%f", &input);
    n = input;

    while ( input > 0 ) {
    printf("Enter a number: ");
    scanf("%f", &input);
        if ( input > n ) {
            n = input;

    printf("the largest number entered was: %f\n", n);

Thanks for the help!

Gary W. Schenk
remove "fuzz" to reply