Ask Question
28 July, 12:45

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.

+3
Answers (1)
  1. 28 July, 14:08
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers