Wednesday, November 24, 2010

write a program to display the position of given element in a array

implicit double precision (a-h,o-z)
    dimension A(11)
    DATA A/1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0/
    write(*,*) 'enter p'
    read(*,*) p
    i=1
    count=1
10    if(p.EQ.A(i)) then
    count=count
      write(*,*) count
    goto 20
    else
    count=count+1
    i=i+1
    goto 10  
20    endif 
    stop
    end

write a program to sum the main diagonal of a matrices (find the trace of a matrices)

implicit double precision (a-h,o-z)
    dimension A(3,3)
    DATA A/1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0/
    C=0
    do i=1,3
    j=i   
    C=C+A(i,j)
    enddo
    write(*,*)C
    stop
    end

write a program to insert a given number into a kth position in array

implicit double precision (a-h,o-z)
    dimension A(10), B(11)
    DATA A/1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 68.0, 8.0, 9.0, 10.0/
    write(*,*) 'enter p'
    read(*,*) p
      write(*,*) 'enter k'
    read(*,*) k
    do i=1,11
    if(i.GE.1.AND.i.lE.k-1) then
    B(i)=A(i)
    endif
    B(k)=p
    if(i.GE.k+1.AND.i.lE.11) then
    B(i)=A(i-1)
      endif
    enddo
    write(*,*) B
    stop
    end

FoRtRaN: Write a program to count even and odd number betwe...

FoRtRaN: Write a program to count even and odd number betwe...: "implicit double precision (a-h,o-z) dimension A(10), B(10) DATA A/1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 68.0, 8.0, 9.0, 10.0/ count=0 ..."

Write a program to count even and odd number between a given one dimensional array

implicit double precision (a-h,o-z)
    dimension A(10), B(10)
    DATA A/1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 68.0, 8.0, 9.0, 10.0/
    count=0
    do i=1,10
    B(i)=mod(A(i),2.0)
   
    if(B(i).EQ.0.0) then
    count=count+1

    else
    count=count
    endif
      enddo
    count1=10-count
    write(*,*) count, count1
    stop
    end

FoRtRaN: Program to find the root of Quadratic Equation

FoRtRaN: Program to find the root of Quadratic Equation: "implicit double precision(a-h,o-z) write(*,*) “please provide the a,b,c coeff” read(*,*) A,B,C D=B*B-4*A*C if(D.GT.0) then root1=(-B/(2*A))..."

FoRtRaN: Program to find area of a triangle whose two sides...

FoRtRaN: Program to find area of a triangle whose two sides...: "implicit double precision(a-h,o-z) write(*,*) “please provide the two sides a and b and the angle” read(*,*) A,B,theta area=A*B*SIN(the..."