Computing Fundamentals - I: Lab Assignment - 3 1. Task #1
Computing Fundamentals - I: Lab Assignment - 3 1. Task #1
Lab Assignment -3
1. Task #1
Examine the output of the following program segment.
1.1. Source Code:
Program task1
I=1
15 IF(I.LE.100) THEN
PRINT*,'I=',I
SUM=SUM+I
I=I+2
GOTO 15
END IF
PRINT*,'SUM=',SUM
End Program task1
1.2. Output Task1
5. Task 05:
Write a program that takes a number n as input from the user and determines its factorial.
5.1. Source Code:
c *****LAB Assignment_4_Factorial*****
Program Factorial
INTEGER input,i,fact !Variable declaration
print*, "Enter a number" !User Input
read*,input
i=1
fact=1
3 do i=1,input
fact=fact*i
end do
print*,'Value of factorial ',input,' is=',fact
End Program factorial
8. Task 08:
Find the Mean and Standard Deviation of five numbers that are taken as input from
user.
8.1. Source Code:
C *****LAB Assignment 4(TASK 08)*****
Program STDM
INTEGERS I,K
real a,input,mean,squaredsum !Variable Declaration
I=0
squaredsum=0
a=0.0
K=1
!This will ask for Enter a Number 1,2,3,4,5 in the input line
1 print*,'Enter a Number ',K,' '
read*,input
!Calculations
I=I+1
K=K+1
a=a+input
Mean=(a)/(5.0)
Squaredsum=(Squaredsum+input**2)
if(i.LE.4) then !Post-test If Loop
goto 1
End if
STDEV=sqrt((SquaredSum/5.0)-mean**2)
print*,"Mean=",Mean
print*,"Standard Deviation=",STDEV
End Program STDM
8.2. Output: