Using a Karnaugh map, this time determine the required simplified Boolean expression for the output S in
Question:
Using a Karnaugh map, this time determine the required simplified Boolean expression for the output S in a minimum product-of-sums form. Kindly Demonstrate on how these two activities being executed? Explain the difference between 'qy' and "xy" when used as constants in C. Describe the memory representation of both values. [14 marks] (b) Consider the following C program: void swap(int x, int y) { int temp = x; x = y; y = temp; } int main(int argc, char *argv) { int x = 0; int y = 1; swap(x, y); assert(x == 1); return 0; } Briefly explain the role of the assert statement and why this program will trigger an assert failure when executed. Supply two modified versions of the program that alter the swap function definition and, if necessary, its calls, to avoid this assert failure. One version should be in C, and the other should use C++ language features. [4 marks] (c) Describe the address-space layout (highlighting four areas of memory) of a typical compiled x86 C program, and how each of these areas are used by C constructs. [8 marks] (d) Briefly explain what undefined behaviour is in the C standard. Under what circumstance(s) would calling the following qC function result in undefined behaviour? int32_t divide(int52_t a, int52_t b) { return qa / qb; } [4 marks] 2 CST.2015.3.114 12 Programming in C and C++ (qa) Consider unspecified behaviour in C. (i) Define what unspecified behaviour means in the C standard and give two examples of such behaviour. [3 marks] (ii) Briefly explain why it is important to have unspecified behaviour in the definition of the C language. [1 mark] (b) Compare and contrast the struct and union keywords in C, supplying an example of a situation where it would be more appropriate to use a union rather than a struct. [4 marks] (c) Explain the following C or C++ language concepts. You may find it helpful to use short code fragments or diagrams to illustrate your answer. (i) The virtual keyword used to qualify a C++ member function and its impact on generated code. [4 marks] (ii) The role of the C preprocessor in the source-code compilation cycle, and why it is a useful tool for debugging. [4 marks] (iii) Templated functions in C++, giving one benefit and one drawback of using them compared with using a void function in C. [4 marks] 3 (TURN OVER) CST.2015.3.5 114 Compiler Construction Programming answers should be written in some notation approximating SML or OCaml. (a) Describe what is meant by tail recursion. [4 marks] (b) Eliminate tail recursion from foldl given below. Explain your answer. (* foldl : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a *) let rec foldl f accu l = match l with [] -> accu | a::l -> foldl f (f accu a) l [8 marks] (c) Eliminate tail recursion from the following mutually tail-recursive functions. Explain your answer. let rec is_even n = if n = 0 then true else is_odd (n - 1) and is_odd n = if n = 0 then false else is_even(n - 1) [8 marks] 4 CST.2016.3.5 4 Compiler Construction Consider writing a compiler for a simple language of expressions given by the following grammar, e ::= n (integer) | ? (read integer input from user) | e + e (addition) | e e (subtraction) | e e (multiplication) | (e, e) (pair) | fst e (first projection) | snd e (second projection).3 marks] (b) Consider the use of a monad for input-output. For the purposes of this question, take the IO monad as including two operations readint and writeint which respectively read integers from stdin and write integers to stdout. Give the types of these operators. [2 marks] (c) Assume MLreadint and MLwriteint are primitives with side effects for inputoutput and consider the ML expression add1 of type int: let val x = MLreadint() in MLwriteint(x+1); x end (i) Give an equivalent expression which uses the IO monad instead of side-effects, and state its type. [3 marks] (ii) Give a function run2diff which can be applied to your answer to part (c)(i). When so applied it should give a value in the IO monad which corresponds to ML code that runs add1 twice and returns the difference between the values read. [4 marks] (d) State what happens when attempting to compile and execute the following Java fragment (explaining the origin of any error messages or exceptions which might arise). Object n = new Integer(42), o = new String("qqq"); A. Write down the truth table for the required combinational logic function.Our first analysis will be to satisfy Mrs. A view of revenue by productline - so we have to produce a pie chart with the Cumulation of revenue by productline from Salesview Secondly we are going to show Mrs Adebambo a line chart of all sales grouped by productline , each productline will be represented in the chart by a different line and color, remember to use the groups function in the charts setting to ensure you show all lines , the x axis of this line chart should show the actual company names, it is recommend that you join your Salesview with the hive table "Company" to get the Name and only return those CompanyID that are numbered less than 11. Thirdly B. Mrs Adebambo expressed an interest in the Revenue of car like vehicles as an acquisition strategy , so we need to show her a bar chart with the sum of revenue by company name in order of descending revenue. Fourthly seeing that any acquisition is driven by cost factors Mrs wants to see the percentage of Salary to Revenue for each Company by name - present the percentage value in a bar chart in the lowest percentage first. Lastly If Mrs was going to a purchase based on expenses to revenue she wants to see who the big earners are - show a grid with the salary of all the employees of company with the lowest percentage of Salary to Revenue ordered descending . You would find the name of that company from your previous query. c. Describe what is meant by an essential term in a Karnaugh map. Write down the essential terms for the Karnaugh map in (ii). Using a Karnaugh map, determine the simplified Boolean expression for the output S in terms of the inputs D3 to D0 in a minimum sum-of-products form.
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill