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
vivado [14]
3 years ago
12

Write a program that asks the user to enter a positive integer that represents a number in the decimal system and then displays

the binary representation of the number. Your solution must include at least the following function: decimalToBinary(number): a recursive function that takes a positive integer number (in decimal) as its parameter and returns a string with it's binary representation. g
Computers and Technology
1 answer:
Maru [420]3 years ago
3 0

Answer:

In Python:

def decimalToBinary(num):

   if num == 0:

       return 0

   else:

       return(num%2 + 10*decimalToBinary(int(num//2)))

       

decimal_number = int(input("Decimal Number: "))

print("Decimal: "+str(decimalToBinary(decimal_number)))

Explanation:

This defines the function

def decimalToBinary(num):

If num is 0, this returns 0

<em>    if num == 0: </em>

<em>        return 0 </em>

If otherwise

   else:

num is divided by 2, the remainder is saved and the result is recursively passed to the function; this is done until the binary representation is gotten

       return(num%2 + 10*decimalToBinary(int(num//2)))

       

The main begins here.

This prompts the user for decimal number

decimal_number = int(input("Decimal Number: "))

This calls the function and prints the binary representation

print("Decimal: "+str(decimalToBinary(decimal_number)))

You might be interested in
Sleeping is an effect of _______ , but agitation may cause a person to wake up
Crank
"Sleeping is an effect of <span>Depressants, but agitation may cause a person to wake up"</span><span />
4 0
2 years ago
Read 2 more answers
Data driven processes: Select one: a. are heavily based on intuition b. rely heavily on the experience of the process owners c.
krek1111 [17]

Answer:

c. are based on statistical data, measurement and metrics

Explanation:

Data driven process are process that are not based on intuition but rather are based on data. This data serves as evidence to back a decision that is to be taken. It therefore means that, whatever decision that will be taken, such a decision will be based on the data presented.

6 0
2 years ago
Levi wants to run 5 commands sequentially, but does not want to create a shell script. He knows that each command is going to ta
disa [49]

Levi can use the bash command to type all the commands on the same line to type one after the other character without requiring input.

<u>Explanation</u>:

  • He wants to run five commands. For one command it will take exactly 20 minutes. So it will take one hour forty minutes.
  • To type all of the commands on the same line Levi should use the bash command. For inserting the bash command Levi should use backslash \ as the last character of the line.
6 0
2 years ago
C++ a. Write a program that uses the function isPalindrome given in example 6-6 (Palindrome). Test your program on the followinn
Whitepunk [10]

Answer:

#include <iostream>

#include <array>

using namespace std;

bool isPalindrome(string str)  

{  

int length = str.length();  

for (int i = 0; i < length / 2; i++)  

 if (toupper(str[i]) != toupper(str[length - 1 - i]))

  return false;  

return true;  

}

int main()

{

array<string, 6> tests = { "madam", "abba", "22", "67876", "444244", "trymEuemYRT" };

for (auto test : tests) {

 cout << test << " is " << (isPalindrome(test) ? "" : "NOT ") << "a palindrome.\n";

}

}

Explanation:

The toupper() addition forces characters to uppercase, thereby making the comparison case insensitive.

5 0
3 years ago
Your organization has an Active Directory domain. One of the users, Bill, should not have read access to a folder named Accounti
Alborosie

Answer: D. Deny read access to the Accounting folder for Bill through shared access security.

Explanation:

The statement that describes how to stop Bill from having read access to the folder without impacting any other users on the network is to deny read access to the Accounting folder for Bill through shared access security.

It should be noted that the local access security cannot be used in this case because the folder is shared from a network server that is within the active directory domain.

5 0
2 years ago
Other questions:
  • 3. Discuss the disadvantages of file-based systems.
    13·1 answer
  • Design an algorithm for a bounded-buffer monitor in which the buffers (portions) are embedded within the monitor itself."
    10·1 answer
  • When you move or size a control in the Form Designer, Visual Studio automatically adjusts the ________________ that specify the
    9·1 answer
  • What statement best describes operating systems?
    12·1 answer
  • Â A number of companies and/or agencies, such as National ____ and Atmospheric Administrationâs National Weather Service, provid
    9·1 answer
  • The measure of how quickly things may be converted to something of value is called.
    10·2 answers
  • In an experiment in which participants sat in an office and then were asked to remember what they saw in the office, participant
    6·1 answer
  • Explain any 10uses of computer that are specific to your field of study giving appropriate examples​
    13·1 answer
  • is a measurement that quantifies how much information can be transmitted over the network. A. Memory B. DMZ C. Bandwidth D. Clou
    10·1 answer
  • Text,Audio and graphic is entered into the computer using
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!