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.
#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;}
In Maths, we often talk about ascending and descending order. Ascending order is writing numbers from smallest to largest. Descending order is writing numbers from largest to smallest.
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, & then divide that result by 2.
1. Read the 3 nos a,b,c 2. Let larget = a 3. if b > largest then largest = b 4. if c > largest then largest = c..... If you have to process more nos, read all of them in an array. Assume the first element be largest, do comparison through all elements of the array.... Similar algorithm can be developed for finding the lowest also. /*lab practice 2 damithguruge question 4 */ #include<stdio.h> int main() { int num1,num2,num3,num4; int smallest; printf("Please enter a number1"); scanf("%d%*c", &num1); printf("Please enter a number2"); scanf("%d%*c" ,&num2); printf("Please enter a number3"); scanf("%d%*c", &num3); Printf("Please enter a numbe4r"); scanf("%d%*c", &num4); /* num1 set as the smallest */ smallest=num1; if(smallest > num2) then smallest=num2; else if smallest >num3 then smallest=num3; else if smallest>num4 then smallest=num4; printf("smallest number:%d\n,smallest"); return(0); endif endif endif }
The former is for strings, the later is for numbers (integers).
the difference
The range.
The largest 5-digit number is 99,999, the smallest is .00001,and the difference is 99,998.99999 .If you only want to consider whole numbers, then the smallest is 10,000and the difference is 89,999 .
86
Range is the difference between the largest and smallest numbers
9999
This difference is called the range. Subtract the smallest value (S) from the largest value (L).Formula: L - S = Difference
the difference between the largest and smallest numbers in data
the difference between the largest and smallest numbers in data
The difference between the largest and smallest numbers in your data set.
The difference between the largest and smallest numbers in a data set is called the range.
The range of a group of numbers is equal to the difference between the smallest and the largest numbers in the group.