1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Mariulka [41]
3 years ago
13

Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binar

y. For an integer x, the algorithm is: As long as x is greater than 0 Output x % 2 (remainder is either 0 or 1) x
Computers and Technology
1 answer:
mylen [45]3 years ago
3 0

Answer:

The program to this question can be described as follows:

Program:

num= int(input('Enter a number: ')) #input value by user

st = '' #defining string variable

while num > 0: #define loop to calculte values binary number

   val= num % 2 # holding remainder (0 or 1) in val variable

   st =st+str(val) # store value in str variable

   num = num//2 #calculte quotient value

print("binary number is: ",st)

Output:

Enter a number: 5

binary number is:  101

Explanation:

Program description as follows:

Firstly the "num" variable is declared, for user input, then an "st" variable is declared, to calculates user input value binary number.

In the next step, a while loop is declared, inside the loop, another variable "Val" is declared, that holds value remainders, which is added on the "st" variable.

Outside the loop, the print method is used, that prints st variable holds value.

You might be interested in
Suppose that a 64MB system memory is built from 64 1MB RAM chips. How many address lines are needed to select one of the memory
alexdok [17]

Answer:

6 address lines

Explanation:

The computation of the number of address lines needed is shown below:

Given that

Total memory = 64MB

= 2^6MB

=2^{26} bytes

Also we know that in 1MB RAM the number of chips is 6

So, the number of address lines is 2^{26} address i..e 26 address lines

And, the size of one chip is equivalent to 1 MB i.e. 2^{20} bytes

For a single 1MB chips of RAM, the number of address lines is

\frac{2^{26}}{2^{20}} \\\\= 2^6 address

Therefore 6 address lines needed

5 0
3 years ago
The objectivity of a site relates to its a. Appearance c. Graphics b. Biases d. Quotes from other Internet authors
nadya68 [22]

The answer is Biases

The objectivity of evaluating a website relates to its ability to present issues based on different points of view. It is based on whether or not the information provided is presented in a fair and balanced way. For example, is the purpose of a certain website like Coca Cola or Pepsi meant to entertain, sell something, or sway public opinion? Do you think these websites will provide information on the negative effects of drinking carbonated beverages? I do not think so! Thus, these websites have bias. Their job is to sell you their product, not to make you think deep about it. We need to ask ourselves more questions about the websites we visit. Is this website balanced or biased in a way it presents information?


5 0
3 years ago
Read 2 more answers
Write a recursive method called repeat that accepts a string s and an integer n as parameters and that returns s concatenated to
svp [43]

Answer:

public static String repeat(String text, int repeatCount) {

   if(repeatCount < 0) {

       throw new IllegalArgumentException("repeat count should be either 0 or a positive value");

   }

   if(repeatCount == 0) {

       return "";

   } else {

       return text + repeat(text, repeatCount-1);

   }

}

Explanation:

Here repeatCount is an int value.

at first we will check if repeatCount is non negative number and if it is code will throw exception.

If the value is 0 then we will return ""

If the value is >0 then recursive function is called again untill the repeatCount value is 0.

6 0
3 years ago
/*
Lera25 [3.4K]

Answer:

The answer to this question can be given as:

Method:

public static void showTwos(int number)  //method definition.

{

method body.  

System.out.print(number + " = ");  //print number

while (number % 2 == 0)   //condition

{

System.out.print("2 * ");    //print message.

number = number / 2;

}

System.out.println(number);    //print value.

}

Explanation:

In the above method definition firstly, we declare the method showTwos() that name is already given in the question then we pass a variable number as a parameter in the method. In this first, we take input number from the user and pass into this method. In this method we use a while loop it is an entry control loop in this loop first we modules the number if it is equal to 0.Then we divide the number by 2 and in the last, we print the value.

4 0
2 years ago
Which statement is correct about operating systems? They are hardware devices. They include programs that help people do certain
katrin2010 [14]
<span>They include programs that help people do certain tasks. They include programs that control a computer. They store information being used by the CPU.</span>
3 0
2 years ago
Other questions:
  • A program called the ______ combines the object program with other programs in the library and is used in the program to create
    5·1 answer
  • Which option in presentation software can you use to apply a “fly in” effect to the objects on a slide? A)flowchart B)shapes C)
    11·2 answers
  • Select the statements that are true regarding the future of technology. Select 2 options.
    12·1 answer
  • What was the first computer programming language?
    7·2 answers
  • What is the largest value that can be represented by 6 binary digits? .
    5·1 answer
  • Which type of storage disk and disk drive can you use in the given situation?
    12·1 answer
  • 1 punto
    11·1 answer
  • Ethan wants to change the font in his document. He should _____.
    8·1 answer
  • Area Triangolo Rettangolo in c++
    6·1 answer
  • Which code snippet is the correct way to rewrite this in Semantic HTML?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!