	real mean		!would have been an integer
	real x(50)		!same as "dimension x(50)"
	character r*1

	print 100
100	format('enter the number of data points ',$)
	read*,n

! finding standard deviation: method 1
	sum=0
	sum2=0
	do  i=1,n
		print 101,i
101		format(i2,'th data point = ',$)
		read*,x(i)
		sum=sum+x(i)
		sum2=sum2+x(i)**2
	enddo

	sdev1=sqrt( (sum2-(sum**2)/n)/(n-1) )
	mean=sum/n

! finding standard deviation: method 2
	sdev2=0
	do i=1,n
		sdev2=sdev2+(x(i)-mean)**2
	enddo

	sdev2=sqrt(sdev2/(n-1))

C
C the two methods start to differ when (sdev/mean)<2e-4
C

	print 102,mean,sdev1,sdev2
102	format(1x,'mean= ',g15.7,' standard deviation method 1 = ',g15.7,/t24,
     1	 'standard deviation method 2 = ',g15.7)
!    ^ this number in column 6 means line continuation

	print 103
103	format('Do you want to write this data to a file? [Y/N] ',$)
	read *,r
	if(r.eq.'y'.or.r.eq.'Y')then
		open(unit=10,file='my_file.dat',status='new')
		write(10,'(g15.7)') (x(i), i=1,n)
		close(unit=10)
	endif
	end
