Computer Science, asked by spsingh777777sp, 8 months ago

write a FORTRAN program to find the maximum among three numbers​

Answers

Answered by ayushkumargautam852
3

Answer:

Set greatest number to the value of the first number.

Compare numbers 2 and 3 with the current largest number:

If the currently compared number is larger then the current largest number, set the current largest number to the value of the currently compared number.

Output the value of the current largest number.

Here is a flowchart for three numbers (A, B, C) that initializes the values of A, B, C before reading their values:

Here is how it could be implemented in a program that runs in a Fortran 95 compiler:

program greatest_number

integer number_of_numbers, i

real numbers(1:huge(number_of_numbers)), greatest

print *, "How many numbers would you like to compare?"

read *, number_of_numbers

do i = 1, number_of_numbers

print *, "Enter number", i

read *, numbers(i)

enddo

greatest = numbers(1)

do i = 2, number_of_numbers

if (numbers(i) .GT. greatest) then

greatest = numbers(i)

endif

enddo

print *, "The greatest given number is", greatest

end program greatest_number

You can copy/paste/run the program here:

Online Fortran Compiler - Online Fortran Editor - Online Fortran IDE - Fortran Coding Online - Practice Fortran Online - Execute Fortran Online - Compile Fortran Online - Run Fortran Online

You need to enter the number of numbers you would like to compare and the values for the numbers to be compared in the STDIN tab on separate lines, such as

3

8.51

7.9

2019

and then click the EXECUTE tab to run the program. The results will appear in the right hand side of the window.

It is close enough to pseudocode that you should be able to translate it to the imperative programming language of your choice.

Hope this helps and does not mislead or confuse you.

16.6K viewsView Upvoters

5

Answered by aateysham
0

Answer:

what ??? oaok oahhha mjjab ooihan gai iag

Similar questions