티스토리 뷰




PROGRAM Half_Adder
!---------------------------------------------------------------------------------
!	Program to calculate the outputs from a logical circuit that
!	Represents a binary half-adder. Variables used are:
!		A, B				: the two logical inputs to the circuit
!		Sum, Carry	: the two logical outputs
!
!	Input		: The two logical inputs A and B
!	Output	: The two logical outputs Sum and Carry, which represent the
!				sum and carry that result when the input values are added
!---------------------------------------------------------------------------------

	IMPLICIT NONE
	LOGICAL :: A, B, Sum, Carry
	
	PRINT *, "Enter logical inputs A and B:"
	READ *, A, B
	Sum = (A .OR. B) .AND. .NOT. (A .AND. B)
	Carry = A .AND. B
	PRINT *, "Carry, Sum =", Carry, Sum
	
	pause
End PROGRAM Half_Adder




 
 

'노트 > Fortran 연습' 카테고리의 다른 글

Program 4.1. 곱셈표의 출력  (0) 2014.04.27
Program 3.4. 오염지수 3  (0) 2014.04.06
Program 3.3. 오염지수 2  (0) 2014.04.06
Program 3.2. 오염지수  (0) 2014.04.06
Program 3.1. 이차 방정식  (0) 2014.04.06
Program 2.Exercise6.2. 온도 변환 (2nd Version)  (0) 2014.03.23
Program 2.Exercise6.1. 온도 변환 (1st Version)  (0) 2014.03.23
Program 2.Exercise5  (0) 2014.03.23
Program 2.1. 발사체 문제  (0) 2014.03.22
Program 1.Exercise10  (0) 2014.03.22