/ Published in: Fortran
This is a piece of code to draw a triangle pattern in the upper diagonal elements. It is a basic exercise of programming.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
program triangle_pattern integer :: i = 0; integer :: j = 0; integer :: n = 3; do while (i<n) j = 0; do while (j<n) if (j>=i) then write(*,"(A)",advance="no") " *" else write(*,"(A)",advance="no") " ." end if j=j+1; end do i = i +1; print *,"" end do read *, end program triangle_pattern