G
G
Giha2020-11-09 15:27:33
Pascal
Giha, 2020-11-09 15:27:33

Truth table through values ​​0 and 1?

Tell me how to display the correct value in the Not A column if a variable of type Integer does not work with the not operation?

begin
  Writeln(' A ',' B ', ' not A ', 'A and B', ' A or B', ' A xor B');
  for var A:=0 to 1 do
    for var B:=0 to 1 do
      Writeln (A:2, B:3, not A:5, A and B:7, A or B:7, A xor B:7);
end.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Yuriev, 2020-11-09
@Giha

I almost shed a tear from nostalgia)
FreePascal dialect:

program Project1;

var
  t0, intA, intB: Byte;
  A, B: boolean;

const
  t = 10;

begin
t0:=t-3;
Writeln('A':t0,'B':t0, 'not A':t, 'A and B':t, 'A or B':t, 'A xor B':t);

for intA:=0 to 1 do
  for intB:=0 to 1 do
    begin
      A:=intA <> 0;
      B:=intB <> 0;
      Writeln (A:t0, B:t0, not A:t, A and B:t, A or B:t, A xor B:t);
    end;

end.

$ ./Project1
      A      B     not A   A and B    A or B   A xor B
  FALSE  FALSE      TRUE     FALSE     FALSE     FALSE
  FALSE   TRUE      TRUE     FALSE      TRUE      TRUE
   TRUE  FALSE     FALSE     FALSE      TRUE      TRUE
   TRUE   TRUE     FALSE      TRUE      TRUE     FALSE

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question