Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For the following program, trace the output and write the results in exact FORMA

ID: 3853440 • Letter: F

Question

For the following program, trace the output and write the results in exact FORMAT in the given table. PROGRAM Learn_Format_part_I IMPLICIT NONE INTEGER, PARAMETER:: MAXIMUM = 5 INTEGER:: I REAL:: a = 203.67, b = -84569.257 DO I = 1, MAXIMUM WRITE(*, "(lx, 216)") I, I*I END DO WRITE(*, "(lx, 2F12.7)") a, b END PROGRAM Learn_Format_part_I For the following FORMAT statement, write the exact output in the table given below. CHARACTER(LEN-5):: a - "12345" CHARACTER:: b = "?" WRITE(*, "(lx, A1, A)")a, b WRITE(*, "(lx, A3, A)") a, b WRITE(*, "(lx, A5, A)")a, b

Explanation / Answer

NOTE: I dont have the table format shown in assignment, so what i did is print the numbers(1 to 40) before printing code output. So it would be useful for you to fill the table by counting the digits where the output has come. Please let me know if you have any questions.

My recommendation is to copy the code and execute in your system. Because while copying the output might differ.

Code:
program Learn_Format_part_I
IMPLICIT NONE
INTEGER, PARAMETER:: MAXIMUM = 5
INTEGER:: I
REAL:: a = 203.67, b = -84569.257
  
DO I = 1, 40
write (*,"(I0)",advance='no') I
END DO

WRITE(*, '(A)')

DO I = 1, MAXIMUM
WRITE(*, "(1x, 2I6)") I, I*I
END DO
WRITE(*, "(1x, 2F12.7)") a, b
  
end program Learn_Format_part_I


Execution and output:
sh-4.3$ main   
12345678910111213141516171819202122232425262728293031323334353637383940
1 1
2 4
3 9
4 16
5 25
203.6699982************


Code:
program Learn_Format_part_II
CHARACTER(LEN=5)::a = "12345"
CHARACTER::b = "?"
  
DO I = 1, 10
write (*,"(I0)",advance='no') I
END DO
  
write(*,'(A)')
  
WRITE(*, "(1x, A1, A)") a,b
WRITE(*, "(1x, A3, A)") a,b
WRITE(*, "(1x, A5, A)") a,b

end program Learn_Format_part_II


Execution and output:
sh-4.3$ main   
12345678910
1?
123?
12345?

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote