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 +...
Consider the following if statement, where doesSignificantWork, makesBreakthrough, and nobelPrizeCandidate are all boolean variables: if doesSignificantWork : if makesBreakthrough : nobelPrizeCandidate = True else nobelPrizeCandidate = False elif not doesSignificantWork: nobelPrizeCandidate = False (assume that doesSignificantWork and makesBreakthrough have been initialized, there is no error) First, write a simpler if statement that is equivalent to this one. Then write a single assignment statement that does the same thing. (Hint: Try to trace this piece of code with all possible initial...
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...
Multiple choice data structures questions about stacks. Here is an INCORRECT pseudocode for the algorithm which is supposed to determine whether a sequence of parentheses is balanced: declare a character stack while ( more input is available) { read a character if ( the character is a '(' ) push it on the stack else if ( the character is a ')' and the stack is not empty ) pop a character off the stack else print "unbalanced" and exit...
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.