answersLogoWhite

0

This sounds like a homework assignment, so I will give you some pseudo code instead of straight C code.

[code]

OPEN FILE FOR READING

IF NOT END OF FILE THEN

min = READ FILE INPUT

max = min

ENDIF

WHILE NOT END OF FILE

x = READ FILE INPUT

IF x < min THEN

min = x

ENDIF

IF x > max THEN

max = x

ENDIF

ENDWHILE

CLOSE FILE

[/code]

If you are using C, then you will need to use fopen(), scanf(), fclose() and maybe feof(). If you are using C++ then you can use fstream, must like you would use cin, except that you have to open the stream, check for end of file and close it.

User Avatar

Wiki User

14y ago

What else can I help you with?

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.


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.


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 }

Related Questions

What is the smallest and largest 2 digit prime numbers?

The smallest is 11 and the largest is 97.


What is the smallest multiple of the first ten natural numbers?

2520 is the smallest multiple of of first ten natural numbers.


What is the sum of the smallest and largest prime numbers within 10?

The sum of the smallest and largest prime numbers within 10 is 7.


Why is 1 the smallest natural number?

The natural numbers are the numbers used to count things (the counting numbers). The smallest number of things you can have when you have some to count is one. Thus the smallest natural number is 1.


How do you sort three ascending numbers?

Highlight the numbers and click on the sort button. You can sort ascending (smallest to largest) or descending (largest to smallest).


When numbers are largest to smallest?

descending order


Order these numbers from smallest to largest?

Done!


How many three-digits natural numbers are there of the form htu where htu?

The smallest one is 100. The largest one is 999. There are 900 of them.


Spread between the smallest and largest numbers in a range of numbers?

Relative


What is the largest and smallest palindromic numbers?

I guess that the smallest would be zero, if you don't consider negative numbers. There is no largest palindromic number - you can make them as large as you like.


What is difference between the smallest and largest numbers?

the difference


What is the smallest and largest prime numbers with in 30?

The smallest prime number between 0 and 30 is 2, and the largest is 29.