0
program diziler
    implicit none
    integer :: N, i
    real :: arr(N), sum, mean, stddev, var
    
    ! Get the value of N
    write(*,'(A)') "Enter the number of elements in the array:"
    read(*,'(I)') N
    
    ! Get the elements of the array
    write(*,'(A)') "Enter the elements of the array:"
    do i = 1, N
        read(*,'(F)') arr(i)
        sum = sum + arr(i)
    end do
    
    ! Calculate the mean
    mean = sum / N
    
    ! Calculate the variance
    do i = 1, N
        var = var + (arr(i) - mean)**2
    end do
    var = var / N
    
    ! Calculate the standard deviation
    stddev = sqrt(var)
    
    ! Print the results
    write(*,'(A,F)') "Mean: ", mean
    write(*,'(A,F)') "Standard deviation: ", stddev
end program diziler

it gives error like this

C:\Users\Teknik\Desktop\6.odev.F95(8) : error 270 - Missing width count for 'I' descriptor
C:\Users\Teknik\Desktop\6.odev.F95(13) : error 270 - Missing width count for 'F' descriptor
C:\Users\Teknik\Desktop\6.odev.F95(30) : error 270 - Missing width count for 'F' descriptor
C:\Users\Teknik\Desktop\6.odev.F95(31) : error 270 - Missing width count for 'F' descriptor
C:\Users\Teknik\Desktop\6.odev.F95(3) : error 542 - N appears in the dimension of a variable, yet is not a dummy argument, a variable available through USE or CONTAINS association, a COMMON variable, a PARAMETER, or
Ian Bush
  • 6,996
  • 1
  • 21
  • 27
  • sorry for pasting the crappy code – pc fortran Jan 11 '23 at 18:34
  • Is any of the information at https://stackoverflow.com/questions/40797875/fortran-error-with-the-format-statement helpful to you? – Jeff Scott Brown Jan 11 '23 at 18:40
  • We prefer questions to focus on single problems, rather than wanting to address many different compiler errors at once. Here you have two different issues: needing to specify field widths when reading values; using a dynamic (based on runtime value) size for an array. You can find answers to each of these different problems across the linked questions. Specify field widths, or use list-directed input, and use an allocatable array. – francescalus Jan 11 '23 at 18:54
  • Please take the [tour] and see [ask]. Use the code editting features in the question editor. As it stands, the fomatting of your post is completely broken. You cand find more in the [help]. – Vladimir F Героям слава Jan 11 '23 at 19:22

0 Answers0