Ask Question
10 June, 20:18

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 0 or a negative number, the program must display the largest nonnegative number entered:Enter a number:60Enter a number:38.3Enter a number:4.89Enter a number:100.62Enter a number:75.2295Enter a number: 0The largest number entered was 100.62.

+1
Answers (1)
  1. 10 June, 20:37
    0
    Here is c program:

    #include

    #include

    void main ()

    {

    //Variable declaration

    //array to hold 6 values you can change this as needed

    float nums[6];

    //integer i is for loop variable

    int i;

    //to hold maximum value

    float max=0.0;

    //clear screen

    clrscr ();

    //iterate 6 times you can change as per your need

    for (i=0; i<6; i++)

    {

    printf ("Enter a number:");

    scanf ("%f",&nums[i]);

    //check if entered value is greater than previous value

    //if it is greater then assign it

    if (nums[i]>max)

    max = nums[i];

    }

    //print the value

    printf ("The largest number entered was %f", max);

    getch ();

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “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 ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers