Saturday, November 24, 2012

sum of series using do statement

** Find sum of the series
 


1234567890
              Write(*,*) 'Enter the value of N'
               Read(*,*) N
                Sum =0.0
               Do m=1,N
               Sum =sum +(1/float(m))
               End do
               Write(*,*) ‘The result is = ' , sum
                End
(Here we use the float for converting the integer number into real . Because 1 is integer and m is also integer so in fortran the division of two integer is also integer . So we make the integer m into real . Because the division of integer and real will be a real . So we convert m into real).(এখানে আমরা float ব্যাবহার করেছি কারণ integer এবং  integer ভাগফল একটি integer ই হবে। তাই আমরা integer m কে float ব্যাবহার করে real এ পরিণত কনেছি যাতে integer ভাগ real এর ভাগফল একটি real হয়।)

**Find the sum of series
 


1234567890
             Write(*,*) 'Enter the value of n'
              Read(*,*) n
               Write(*,*) 'Enter the value of x'
              Read(*,*) x
               Sum = 0.0
              Do m =1,N
              Sum = sum + (x**m/float(m))
              End do
               Write(*,*) 'The result of the series is = ' , sum
               End

  Just copy and paste this problem on your Force 2.0 and run and put the values up to x and n you will get the result
Here the value of x and n is fixed and the value of m is variable (1,2,3,4……..n)
 ** Find the sum of the series



1234567890
             write(*,*) 'enter the value of n'
              read(*,*) n
             Sum = 0.0               
             Do k = 1,n
             Sum = sum + (k**2/float((2*k-1)))
              End do
              Write(*,*) ' The result of the sum is = ' , sum
               End
                
             
(Here we need to input n . Here n = 10 Because 10 square = 100 and (2*10)-1 = 19 and here k is itself a variable and it varies as
 k=1, 2, 3 , ………,10.






No comments:

Post a Comment