Computer Science Canada

How to make a Gate code in turing..here I used XOR....

Author:  GB [ Mon Dec 13, 2004 2:40 pm ]
Post subject:  How to make a Gate code in turing..here I used XOR....

code:

%XOR GATE
var a, b : int
loop
    put "What is the input for A?"
    get a
    if a > 1 or a < 0 then
        put "Error"
    else
        exit
    end if
end loop
loop
    put "What is the input for B?"
    get b
    if b > 1 or b < 0 then
        put "Error"
    else
        exit
    end if
end loop
if a = 0 and b = 0 then
    put "Y = 0"
elsif a = 0 and b = 1 then
    put "Y = 1"
elsif a = 1 and b = 0 then
    put "Y = 1"
else
    put "Y = 0"
end if

Author:  cool dude [ Mon Dec 13, 2004 5:54 pm ]
Post subject: 

it would be better if u made it for all the gates but it's still good for people that can't remember a little truth table.


: