Skip to main content

Program to find sum of the series 2 + 4 + 2 + 4 + 2 + ... upto a no. of terms

C       Program to find sum of the series 2 + 4 + 2 + 4 + 2 + ... upto a no. of terms
        write(*,*)'Input the no. of terms:'
        read(*,*)n
        sum=0
        p=2
        do i=1,n
        sum=sum+p
        p=6-p
        end do
        write(*,*)'The sum of the given series is:',sum
        end
       

Comments