Logic Gate โดยเครื่องหมาย & และ ||

โดยปกติแล้วคอมพิวเตอร์จะสื่อสารด้วย 0 และ 1 ซึ่งก็เป็นการสื่อสารแบบ Digital

Digital ก็จะมี Logic Gate หลักๆ อยู่ แบบ (And / Or / Not-and / Not -or / Excursive Or / Excursive Not Or  )

ถ้าเรากำหนดให้ใส่ input X และ Y เป็น 0 หรือ 1

Pseudo Code

Input int X

Input int Y

If (X == 0)

{nx == 1}

If (X == 1)

{nx ==0}

If (Y == 0)

{ny == 1}

If (Y == 1)

{nY ==0}

If ((X == 1 ) || X==0) && ((Y==1) ||(Y==0))

{

If ( X&&Y) == 1

{ print “X and Y = 1” }

else

{ print “X and Y = 0”} // And gate

If ( X&&Y) == 1

{ print “X and Y = 0” }

else

{ print “X and Y = 1”} // Not – And gate

If ( X || Y) == 1

{ print “X  or Y = 1” }

else

{ print “X or Y = 0”} // Or gate

If ( X || Y) == 1

{ print “X  or Y = 0” }

else

{ print “X or Y = 1”} // Not – Or gate

If ( (X&&ny) ||(nx && Y) == 1

{ print “X  xor Y = 1” }

else

{ print “X or Y = 0”} // Excursive Or gate

If ( (X&&ny) ||(nx && Y) == 1

{ print “X  xor Y = 0” }

else

{ print “X or Y = 1”} // Excursive Not Or gate

Flowchart

logic Fin - New Page

Video

YouTube Preview Image

Thummathus Boonlerd
at GlurGeek.Com

Leave a Reply

© 2022 GlurGeek.Com