C Program to find the scalar product of two vectors
dimension x(20),y(20)
product=0.0
write(*,*)'Enter the total no. components in each vector:'
read(*,*)n
write(*,*)'Enter the components of the first vector:'
do i=1,n
read(*,*)x(i)
end do
write(*,*)'Enter the components of the second vector:'
do i=1,n
read(*,*)y(i)
end do
do i=1,n
product=product+x(i)*y(i)
end do
write(*,*)'The scaler product of the vectors :',product
end
dimension x(20),y(20)
product=0.0
write(*,*)'Enter the total no. components in each vector:'
read(*,*)n
write(*,*)'Enter the components of the first vector:'
do i=1,n
read(*,*)x(i)
end do
write(*,*)'Enter the components of the second vector:'
do i=1,n
read(*,*)y(i)
end do
do i=1,n
product=product+x(i)*y(i)
end do
write(*,*)'The scaler product of the vectors :',product
end
Comments
Post a Comment