Answer: a. not (isCheap(x)) or isSoldout(x):
Boolean example:
isCheap(x) and not(isSoldout(x))
A and not B:
Applying negation to that would be:
not A or B
not isCheap(x) or isSoldout(x) is the answer
Consider the following piece of pseudocode: if (ischeap (x) and not (issoldout(x))) then print ("Buy it!");...
A) Rewrite the following pseudocode segment in C++ using the loop structures (for and while). Assume that all the variables are declared and initialized. k-G+ 13)/27 loop: if k> 10 then goto out k=k+1 i=3"k-1 goto loop I out: B) Rewrite the following code segment in C++ using the multiple-selection (switch and if-else) statements. Assume that all the variables are declared and initialized. if((k 1) || (k 2))j-2 k-1 if ((k 3) || ( ks))j - 3.k+1 if (k 4)j-4k-1...
Consider the following pseudocode Xinteger procedure set x(n global integer) Xin procedure print x write integer(x) procedure first set x(1) print x procedure second xinteger set x(2) print x set x(e) first() print x second print x What does this program print if the language uses static scoping? What does it print with dynamic scoping? Why?
Consider the following pseudocode which uses dynamic scoping. What does the program print if the language uses shallow binding? What does it print with deep binding? x: integer//global procedure print_x write_integer (x) procedure first x:= x * 3 procedure second (F: procedure) x: integer x: = 5 F () print_x () x: = 7 second (first) print_x ()
Re-write the following if statement structure as a SWITCH/CASE statement in C++ and Pseudocode: X ← 1 A ← 3 IF (a is equal to 1) THEN x ← x + 5 ELSE IF (a is equal to 2) THEN x ← x + 10 ELSE IF (a is equal to 3) THEN x ← x + 15 ELSE IF (a is equal to 4) THEN x ← x +...
Will rate, thank you. Consider the following pseudocode, assuming nested subroutines, lexical scope, and that local variables (including formal parameters) are stored in the stack. procedure main() g: integer procedure B(a: integer) x: integer procedure A(n: integer) g := n procedure R(m: integer) write_integer (x) x := x/2 -- integer division if x > 1 R(m + 1) else A (m) --body of B x := a * a R(1) --body of main B(3) write_integer(g) (a) What does this program...
We want to create a program which prints off what letter grade an individual receives based upon whether or not their grade obeys the following condition: grade>= 90 and grade = 80 and grade<89, we will print off “You made a B”, so on and so forth. In this program, we can assume that we are asking the user to enter whatever grade they recieved as a numeric input. NEED HELP WITH ALL PARTS! 4.) Consider the example of grades...
ESRB Ratings ─ Pseudocode The following rules are a modified version of the rules used to describe how to categorize video games into one of four Entertainment Software Rating Board (ESRB) categories – Mature (M). Teen (T), Everyone (E), Unknown (U). If the game has intense violence or sexual content, then it should be rated Mature. If the game has some violence or some strong language, then it should be rated Teen. If the game has mild content, then it...
Consider the following pseudocode. int a = 9; //global variable void go {a = a +2; print a; } main { int a = 4; 80: a = a +1; print a; } a. What is printed out if we are using static scope rules? Show runtime stack. b. What is printed out if we are using dynamic scope rules? Show calling tree.
Explain please II. (7 points) Consider the following bit of pseudocode: for (int k = 1; ks Ign; k++) (for (int i = 1; i r: i++) Print "Hello World"; for (int j-1;jsn:j++) Print "Hello World" when n = 2, how many times will "Hello World" be printed? When n 4, how many times will "Hello World be printed? O Assuming that the print is the basic operation, what is the complexity function of this pseudocode? II. (7 points) Consider...
Consider the following incomplete code segment, which is intended to print the sum of the digits in num. For example, when num is 12345, the code segment should print 15, which represents the sum 1 + 2 + 3 + 4 + 5. int num = 12345; int sum = 0; /* missing loop header */ { sum += num % 10; num /= 10; } System.out.println(sum); Which of the following should replace /* missing loop header */ so that the...