Writing a program to find the largest in a series of numbers.
12:32 23 May 2013

I am very new to C. I am using A modern Approach to C programming by King 2nd Edition.

I am stuck on chapter 6. Question 1: Write a program that finds the largest in a series of numbers entered by the user. The program must prompt the user to enter the numbers one by one. When the user enters 0 or a negative number, the program must display the largest non negative number entered.

So far I have:

#include 

int main(void)
{
float a, max, b; 

for (a == max; a != 0; a++) {
printf("Enter number:");
scanf("%f", &a);
}

printf("Largest non negative number: %f", max);

return 0;
}

I do not understand the last part of the question, which is how to see which non-negative number is the greatest at the end of user input of the loop.

max = a > a ???

Thanks for your help!

c scanf