I've looked around for some help on this but I can only find how to sort for a specific array size. The directions are as follows:
Write a program that finds the largest in a series of numbers entered by the user. The program must prompt the user to enter numbers one by one. When the user enters a 0 or a negative number, the program must display the largest nonnegative number entered.
Here is what I have so far:
I am using bloodshed if that makes any difference, please let me know what I need to change, thanks.Code:int main(int argc, char *argv[]) { /*This program will find the largest number in a series of positive numbers */ /*entered one number at a time. Enter a 0 or negative number to end the loop*/ int n, temp; int counter = 1; int largest = 0; printf("Enter a number:"); scanf("%d", &n); while(n > 0) { printf("Enter a number:"); scanf("%d", &n); } while(n <= 0) { while(counter <= n) { if(n > largest) { temp = 0; temp = largest; largest = n; } else if(n < largest); { temp = 0; temp = largest; largest = largest; } counter++; printf("The largerst number is: %d", &largest); } } system("PAUSE"); return 0; }



LinkBack URL
About LinkBacks






