answersLogoWhite

0


Best Answer

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.

User Avatar

Wiki User

9y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: 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?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Write a program that will find the smallest largest and average values in a collection of N numbers Get the value of N before scanning each value in the collection of N numbers?

#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;}


What does descending mean in maths?

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.


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.


Write algorithm of a largest number in three numbers?

1. Read the 3 nos a,b,c 2. Let larget = a 3. if b &gt; largest then largest = b 4. if c &gt; 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&lt;stdio.h&gt; int main() { int num1,num2,num3,num4; int smallest; printf("Please enter a number1"); scanf("%d%*c", &amp;num1); printf("Please enter a number2"); scanf("%d%*c" ,&amp;num2); printf("Please enter a number3"); scanf("%d%*c", &amp;num3); Printf("Please enter a numbe4r"); scanf("%d%*c", &amp;num4); /* num1 set as the smallest */ smallest=num1; if(smallest &gt; num2) then smallest=num2; else if smallest &gt;num3 then smallest=num3; else if smallest&gt;num4 then smallest=num4; printf("smallest number:%d\n,smallest"); return(0); endif endif endif }


What is the difference between varchar and int?

The former is for strings, the later is for numbers (integers).

Related questions

What is difference between the smallest and largest numbers?

the difference


What is the difference between the smallest and largest numbers in a group?

The range.


What is the difference between the largest and the smallest 5-digit numbers?

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 .


What is the difference between the smallest and largest two digit prime numbers?

86


What is range in maths terms?

Range is the difference between the largest and smallest numbers


What is the difference between the largest and smallest 4 digit numbers you can make?

9999


What is the difference between the largest and the smallest values in a set of numbers?

This difference is called the range. Subtract the smallest value (S) from the largest value (L).Formula: L - S = Difference


What mountain range is in northeast Afghanistan?

the difference between the largest and smallest numbers in data


Choose the definition that fits this term.range?

the difference between the largest and smallest numbers in data


What does range of data mean?

The difference between the largest and smallest numbers in your data set.


What is the difference between the greatest and least numbers in a set of data?

The difference between the largest and smallest numbers in a data set is called the range.


How do you work out the range in maths?

The range of a group of numbers is equal to the difference between the smallest and the largest numbers in the group.