
write a program that gets a list of double numbers from user and
output the largest and smallest one by using array
intro Computer science problem
Dear student,
below i have written the C program as per the requirement. Please note that i have also commneted out the each line of code to make you understand the logic.
see the attached output below..
Please note the below program has been tested on ubuntu 16.04 system and compiled using gcc compiler. This code will also work on code blocks.
-----------------------------------------------------------------------------------------------------------------------------------
Program:
------------------------------------------------------------------------------------------------------------------------------------
//headers
#include<stdio.h>
//start of main function
int main()
{
//array of size 100 declration
double array[100];
//variable data type declration
int i, N;
//ask about input value
printf("Enter number of elements in the array: ");
scanf("%d", &N);
printf("Please enter %d elements..\n", N);
//loop for N times
for(i=0; i<N; i++)
{
scanf("%lf", &array[i]);
}
//initialize min and max value to array[0]
double min = array[0];
double max = array[0];
//loop for N times
for(i=0; i< N; i++)
{
//find min element
if(array[i] < min)
{
min = array[i];
}
//find max element
else if(array[i] > max)
{
max = array[i];
}
}
//Display minimum and maximum element
printf("Smallest element in the array is: %0.2lf\n", min);
printf("Largest element in the array is: %0.2lf\n", max);
return 0;
}//end of the main function
-----------------------------------------------------------------------------------------------------------------------------------------
here i have attached the output of the program as a screen shot..
Output:

--------------------------------------------------------------------------------------------------------------------------------------------
Kindly Check and Verify Thanks...!!!
write a program that gets a list of double numbers from user and output the largest...
Write a java program that allows the user to input 20 double type numbers to an array and then output the largest (max) number.
In java, write a program that gets 10 integer numbers from the user using user input, and then calculates and display the sum of the numbers that have been read. Program Requirements: Write the program in three versions with three loops. Put all three loops in the main method of your source code. The program must be in one file. version1: use a while loop. version2: use a do-while loop. version 3: use a for loop. For each version, use a loop to...
In java, write a program that gets 10 integer numbers from the user using user input, and then calculates and display the sum of the numbers that have been read. Program Requirements: Write the program in three versions with three loops. Put all three loops in the main method of your source code. version1: use a while loop. version2: use a do-while loop. version 3: use a for loop. For each version, use a loop to input 10 int numbers from the user...
5.2 Write a program that repeatedly prompts a user for integer numbers until the user enters 'done'. Once 'done' is entered, print out the largest and smallest of the numbers. If the user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the number. Enter 7, 2, bob, 10, and 4 and match the output below. 1 largest = None 2 smallest = None 3 while True: 4...
5.2 Write a program that repeatedly prompts a user for integer numbers until the user enters 'done'. Once 'done' is entered, print out the largest and smallest of the numbers. If the user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the number. Enter 7, 2, bob, 10, and 4 and match the output below. 1 largest = None 2 smallest = None 3 while True: 4 num...
Write a program in C language that gets a list of names from user. The list ends when the user gives ‘quit’. The program should then print all the names provided by the user and the frequency of each name. Assume each name is at most of size 100 characters.
Write a program that will take input from a file of numbers of type double and output the average of the numbers in the file to the screen. Output the file name and average. Allow the user to process multiple files in one run. Part A use an array to hold the values read from the file modify your average function so that it receives an array as input parameter, averages values in an array and returns the average Part...
Write a program that finds either the largest or smallest of the ten numbers as command-line arguments. With –l for largest and –s for smallest number, if the user enters an invalid option, the program should display an error message. Example runs of the program: ./find_largest_smallest –l 5 2 92 424 53 42 8 12 23 41 output: The largest number is 424 ./find_largest_smallest –s 5 2 92 424 53 42 8 12 23 41 output: The smallest number is...
Write a JAVA program to read a list of nonnegative integers and to display the largest integer, the smallest integer and the average of all the integers. The user indicates the end of the input by entering a negative sentinel value that is not used in finding the largest, smallest and average values. The average should be a value of type double so that it is computed a fractional part. * Java program free from syntax, logic and run time...
Write a menu based program implementing the following functions: (0) Write a function called displayMenu that does not take any parameters, but returns an integer representing your user's menu choice. Your program's main function should only comprise of the following: a do/while loop with the displayMenu function call inside the loop body switch/case, or if/else if/ ... for handling the calls of the functions based on the menu choice selected in displayMenu. the do/while loop should always continue as long...