1a) Prove that all boolean logical functions can be expressed using only Nor gates. Place this in a file called "1a.txt" on your desktop.
bool xor(bool a, bool b)Next, write the function norExpansionOfXor:
{
// returns true if and only if (a xor b) is true
}bool nor(bool a, bool b)
{
// returns true if and only if (a nor b) is true
}
bool norExpansionOfXor(bool a, bool b)Finally, in your main() function, simply demonstrate that xor(a,b) equals norExpansionOfXor(a,b) for all 4 possible combinations of a and b (true/true, true/false, false/true, false/false). Be sure to output all 4 values from both functions as well, so your output should begin with something like:
{
// This function uses the nor() function above to compute
// the expansion of Xor from problem (1b).
// Note that this function must call the nor() function,
// and may only call the nor() function.
}
a=false,b=false --> xor(a,b)= false , norExpansionOfXor(a,b)= false
a=false,b=true --> xor(a,b)= true , norExpansionOfXor(a,b)= true
Question 2. Write a SimpSim program (in a file called "2.asm" on your desktop) which, when run, uses the special ASCII symbols to output a box surrounding the letters SA, as in:
Further, your program should assume there is a count in memory location FF, and should print out that many such boxes. Hint: You may want to look at both HelloWorld and OutputTest, which are under the Examples item in the Help menu of SimpSim.
Question 3. Write a C++ program (in a file called "3.cpp") which uses mergeSort to sort lists from largest to smallest (so v[0] is largest). Include a main() which repeatedly tests your sort on vectors of random integers until the user enters a vector size <0. Be sure to print out both the unsorted and the sorted vectors.
Question 4. Write a C++ program (in a file called "4.cpp") which uses Monte Carlo methods to determine the probability that when 2 dice are rolled they come up with a 7 (that is, a 6-1, 5-2, 4-3, 3-4, 2-5, or 1-6).
Question 5. Write a C++ program (n a file called "5.cpp") which repeatedly asks the user for a number (exiting when the input is <0) and outputs the sum of the digits in the number the user entered. Here is some sample output:
Enter a number (<0 to exit): 43The sum of the digits in 43 = 4 + 3 = 7.
Enter a number (<0 to exit): 1904
The sum of the digits in 1904 = 1 + 9 + 0 + 4 = 14.