-
Notifications
You must be signed in to change notification settings - Fork 1
/
Exercise_10.f90
36 lines (35 loc) · 1.08 KB
/
Exercise_10.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
! Created by EverLookNeverSee@GitHub on 6/9/20
! For more information see FCS/img/Exercise_10.png
program main
implicit none
! declaring variables
integer :: i, j, n, tmp
integer , allocatable, dimension(:) :: a
! getting user input in order to specify length of series
do
print *, "Enter the length of series:"
read *, n
! if user input is not a positive integer or is equal to zero
if (n <= 0) then
print *, "Number of elements should be positive integer."
cycle
else ! if user input is a positive integer
exit
end if
end do
! allocating memory space to array
allocate(a(n))
print *, "Enter value of elements:"
! assigning value of elements to array blocks
do i = 1, size(a)
print *, "a(", i, "):"
read*, a(i)
end do
! determining and printing the elements that are divisible by the inteher 3
do j = 1, size(a)
tmp = (a(j) / 3) * 3
if (tmp == a(j)) then
print *, a(j)
end if
end do
end program main