answersLogoWhite

0

#include
#include
#include

int main(int argc, char *argv[]){
int n, smallest, largest, sum, temp;
if(argc < 2){

printf("Syntax: foo val1[val2 [val3 [...]]]\n");
exit(1);

}

smallest = largest = sum = atoi(argv[1]);
for(n = 2; n < argc; n++){
temp = atoi(argv[n]);
if(temp < smallest) smallest = temp;
if(temp > largest) largest = temp;
sum += temp;

}

printf("Smallest: %i\nLargest: %i\nAverage: %i\n", smallest, largest, sum / (argc - 1));
return 0;

}

User Avatar

Wiki User

15y ago

What else can I help you with?

Continue Learning about Engineering

Write a program that randomly fills a 10 component array then prints the largest and smallest values in the array?

final double[] ns = new double[10]; final Random rnd = new Random(System.currentTimeMillis()); // Fill... for (int i = 0; i &lt; ns.length; ++i) { ns[i] = rnd.nextDouble(); } // Get largest/smallest... double largest = Double.MIN_VALUE; double smallest = Double.MAX_VALUE; for (double n : ns) { if (n &gt; largest) { largest = n; } if (n &lt; smallest) { smallest = n; } } // largest and smallest are now the proper values.


To take a neck measurement place the measuring tape?

Around your neck. If you need to know the smallest perimeter, then measure around the smallest part of your neck. If you need to know the largest perimeter, then measure around the largest part of your neck. If you need to know the average perimeter, then measure around the smallest part of your neck AND the largest part of your neck, add the numbers together, &amp; then divide that result by 2.


What are the smallest and the largest integer values for primitive type short?

The smallest value is -32,768 and the maximum is 32,767


How do you write program to read a set of real numbers and find the range is given by the difference between largest and smallest number?

Use the following algorithm (written in pseudocode). Let largest be the lowest possible real number. Let smallest be the greatest possible real number. Repeat while there is input... { Read real number r from input. If r is greater than largest then let largest be r. If r is less than smallest then let smallest be r. } End repeat. Let range be largest minus smallest. Output range.


C program to find the largest and smallest character in a word?

helicopter

Related Questions

How do you calculate an average-of-all-even-numbers-between-1-and-100?

The average of the smallest and the largest even numbers (2 and 98) is 50 The average of the next smallest and the next largest (4 and 96) is 50 The average of the next smallest and the next largest (6 and 94) is 50 and so on. So, the overall average is 50.


How do you average averaged numbers?

The average of the smallest and the largest even numbers (2 and 98) is 50 The average of the next smallest and the next largest (4 and 96) is 50 The average of the next smallest and the next largest (6 and 94) is 50 and so on. So, the overall average is 50.


is uranus the largest or smallest planet in the solar system?

It is only an average size planet. The smallest planet is Pluto, and the largest planet is Jupiter.


Which planet has the smallest orbit and largest orbit how did you arrive at your answer?

Mercury has the smallest orbit, and Neptune has the largest orbit in our solar system. This is determined by the average distance of each planet from the Sun. Mercury's average distance is about 0.39 astronomical units (AU), while Neptune's average distance is about 30.07 AU.


Is neptune the largest 2nd largest or smallest?

Itis neither the largest, second largest or smallest.


What is the average of 74 60 58 72 and 66?

The average of this data is 16. You find the average by subtracting the smallest number by the largest number.


What is the largest and smallest eu members?

By area, France is the largest and Malta is the smallest. By population, Germany is the largest and the smallest is Malta.


According to some probability theories can the solar system exceed the the size of the smallest galaxy?

No. Even the smallest collection of stars would be far larger than even the largest solar system.


What are the the smallest and largest us states?

By area, the largest is Alaska and the smallest is Rhode Island; by population, the largest is California and the smallest is Wyoming.


What is the largest and smallest state in the US?

largest: Alaska smallest: Rhode Island


What are the largest and smallest countries in the Benelux?

The Netherlands is the largest and Luxembourg is the smallest.


Name englands citys largest to smallest?

London is the largest and Ely the smallest.