using System;
class LogiOpsTable
{
static void Main()
{
bool p, q;
Console.WriteLine("P\tQ\tAND\tOR\tXOR\tNOT");
p = true; q = true;
Console.Write(p + "\t" + q + "\t");
Console.Write((p & q) + "\t" + (p | q) + "\t");
Console.WriteLine((p ^ q) + "\t" + (!p));
p = true; q = false;
Console.Write(p + "\t" + q + "\t");
Console.Write((p & q) + "\t" + (p | q) + "\t");
Console.WriteLine((p ^ q) + "\t" + (!p));
p = false; q = true;
Console.Write(p + "\t" + q + "\t");
Console.Write((p & q) + "\t" + (p | q) + "\t");
Console.WriteLine((p ^ q) + "\t" + (!p));
p = false; q = false;
Console.Write(p + "\t" + q + "\t");
Console.Write((p & q) + "\t" + (p | q) + "\t");
Console.WriteLine((p ^ q) + "\t" + (!p));
}
}
5. Compile and run the program. The following table is displayed:
P Q AND OR XOR NOT
true true true true false false
true false false true true false
false true false true true true
false false false false false true
6. On your own, try modifying the program so that it uses and displays 1’s and 0’s, rather than
true and false.
Here is where I'm struggling you are meant to do this with what you have learned previously, which is basically data types, loops and if statements.
Any idea how to make the table display 1 - 0 instead of true - false?
thanks a lot!


Sign In
Create Account

Back to top









