
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question

Transcribed Image Text:Question 23
For the pseudo-code program below, assume that variables x, y, z, n and count hold integer values.
x= 129
у - f1(x)
f2(y)
print x, y, z
Z-
define f1(n)
count=0
while(n > 0)
n = n/2
count count + 1
return count
define f2(count)
n=1
while (count > 0)
n-n2
count count
return n
1
The output of the program will be:

Transcribed Image Text:define f2(count)
1
while (count > 0)
n = n 2
count = count 1
return n
The output of the program will be:
O 129, 7, 256
O 129, 9, 512
O 129, 8, 129
129, 8, 256
O 129, 7, 128
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 5 steps with 2 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Write a program using: 1. FIFOarrow_forwardThe powers of 2 are: 1, 2, 4, 8, 16, 32, .. . Write a program to display the first power of 2, which is bigger than 1000.arrow_forwardWhat is the major advantage of using a for loop instead of a while loop? a. Unlike with a while loop, the execution of multiple statements can depend on the test condition. b. With a for loop, it is impossible to create an infinite loop. c. It is the only way to achieve an indefinite loop. d. The loop control variable is initialized, tested, and altered all in one place.arrow_forward
- Computer ScienceIDENTIFY if TRUE OR FALSEarrow_forwardA dice is an n-sided shape with the sides labelled by numbers 1, 2, ..., n. The most common dice used to play various games is the 6-sided dice. You can however have a dice that has many more sides. Write a C++ program that rolls multiple dice d = 1, 2,..., outputs each dice's roll and the sum of all the rolled dice. At each turn when the dice are rolled, all the dice have the same number of sides n. Your code must do the following • read in a number n dice n and sides d each dice has, then d from a file named input .txt, which represents the number of • generate a random number that would be found on each dice. Write the corresponding numbers from each dice, as well as the sum of all the numbers on each dice to a file named output.txt.arrow_forwardWrite a program to print all fibonacci numbers less than k, where k is a non-negative integer taken input from the user. Given: k < 1000. Programming language: C++arrow_forward
- ASuppose that x and y are variable names that already refer to Boolean values.Write an expression (not a statement!) that evaluates to True iff at least oneof the variables is False.B.Suppose that x, y, and z are variable names that already refer to Boolean values.Write an expression (not a statement!) that evaluates to True iffat least two of the three variables (x, y, z) are True.C. Consider the following function headers and type contracts:def aragorn(x: int, y: str, z: float) -> str:def gandalf(x: list) -> list:def elrond(x: list, y: bool) -> bool:If the following code runs without errors, what is a header and type contractfor treebeard?a = aragorn(11, 'good', 2.0)b = treebeard(5, gandalf([1, 2, 3]), a)print(elrond(gandalf([4, 5]), b))Write the header and type contract for treebeard.arrow_forwardusing C++, refer the the 2 pics attached.arrow_forwardWrite an expression that evaluates to True if the value assigned to X is even, but False if the value is odd.arrow_forward
- A variable like userNum can store a value like an integer. Extend the given program to print userNum values as indicated. (Submit for 2 points). (1) Output the user's input. Enter integer: 4 You entered: 4 (2) Extend to output the input squared and cubed. Hint: Compute squared as userNum * userNum. (Submit for 2 points, so 4 points total). Enter integer: 4 You entered: 4 4 squared is 16 And 4 cub is 64!! (3) Extend to get a second user input into userNum2. Output sum and product. (Submit for 1 point, so 5 points total). Enter integer: 4 You entered: 4 4 squared is 16 And 4 cubed is 64 !! Enter another integer: 5 4 + 5 is 9 4 * 5 is 20 283902.1980792.goazgy7 LAB 1.16.1: Basic output with variables (Java) 0/5 АCTIVITY OutputWithVars.java Load default template. 1 import java.util.Scanner; 2 3 public class OutputwithVars { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int userNum = 0; 4 System.out.println("Enter integer: "); userNum = scnr.nextInt(); 10 11…arrow_forwardA variable like userNum can store a value like an integer. Extend the given program as indicated. 1. Output the user's input. (2 pts) 2. Output the input squared and cubed. Hint: Compute squared as userNum * userNum. (2 pts) 3. Get a second user input into userNum2, and output the sum and product. (1 pt) Note: This zyLab outputs a newline after each user-input prompt. For convenience in the examples below, the user's input value is shown on the next line, but such values don't actually appear as output when the program runs. Enter integer: 4 You entered: 4 4 squared is 16 And 4 cubed is 64!! Enter another integer: 4 + 5 is 9 4 * 5 is 20 367012.2549490.qx3zgy7 LAB 2.13.1: LAB: Warm up: Basic output with variables 0/5 ACTIVITY OutputWithVars.java Load default template... 1 import java.util.Scanner; 2 3 public class OutputWithVars { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int userNum; 4 7 8 System.out.println("Enter integer:"); userNum =…arrow_forwardA typical NMR peak after Fourier transform has a Lorentzian absorptive line shape. This line shape is represented by the function below, where x is in Hz 1 f (x) : x2 + 1 Write a program to calculate the integral of this function using Riemann sums on the range from [-10, 10] (inclusive) with dx = 0.01. In other words, estimate the following integral with a Riemann sum. 10 1 x2 + 1 -10arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education