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]
4 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]4 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
Which of the following are valid values for a boolean value in programming? (Select all that apply)
mrs_skeptik [129]

Answer:

false, true

Explanation:

Boolean values can be represented by just 1 bit in a computer. These can be stored as 1 or 0. In Python you use the True and False keywords to refer to these.

7 0
4 years ago
After an informative session, you find yourself with several pages of notes. For maximum retention and understanding, you should
creativ13 [48]
Hey there!

I would say that you should go over them within the least amount of time as possible. The amount that someone remembers after a lecture or informative session goes down greatly after only a few hours since the lecture, so it's best to review them within 8 hours or so. If you do it within this time, you will still have the greatest possible remembrance of what you learned, since your memory of this continues to diminish over the next few days. 

Hope this helped you out! :-)
7 0
3 years ago
Doctors at a regional hospital access an online database of patient records that is being developed and tested by a conglomerate
shepuryov [24]

Answer:

This seems to be DBaaS, in other words, Database, implementation mostly as a service cloud. A further explanation is given below.

Explanation:

  • DBaaS seems to be a framework for cloud storage that enable participants to choose a standard collection of abstractions to provide, maintain, consume, customize, as well as run databases.
  • Everything just allows consumers with either a treatment process that leads to a database but without specific system configuration, software installation, or performance configuration. Doctors didn't require any database built on certain machines in this situation, because of being able to view every data electronically.
  • Doctors would not have to do database management here since the phone company will require control of it. Accessing the documents what they'd have to do. Any further rights can be obtained through proper permits, such as data upgrading respectively.
4 0
3 years ago
Operating systems that have windows and icons have which type of user interface?
777dan777 [17]
A GUI (Graphical User Interface)
4 0
4 years ago
Read integers from input and store each integer into a vector until -1 is read. Do not store -1 into the vector. Then, output al
weqwewe [10]

Answer:

The program in C++ is as follows:

#include <iostream>

#include <vector>

using namespace std;

int main(){

vector<int> nums;

int num;

cin>>num;

while(num != -1){

 nums.push_back(num);

 cin>>num; }  

for (auto i = nums.begin(); i != nums.end(); ++i){

    cout << *i <<endl; }

return 0;

}

Explanation:

This declares the vector

vector<int> nums;

This declares an integer variable for each input

int num;

This gets the first input

cin>>num;

This loop is repeated until user enters -1

while(num != -1){

Saves user input into the vector

 nums.push_back(num);

Get another input from the user

 cin>>num; }

The following iteration print the vector elements

<em> for (auto i = nums.begin(); i != nums.end(); ++i){ </em>

<em>     cout << *i <<endl; } </em>

6 0
3 years ago
Other questions:
  • According to the appendix what was the purpose of newspeak
    12·1 answer
  • An outline is most like which of the following?
    7·1 answer
  • Assume you have a byte-addressable machine that uses 32-bit word (integers are 32-bit) and you are storing the following informa
    5·1 answer
  • It is important for a writter to include voice and point of view in writting because _______
    11·1 answer
  • Can someone please help??
    12·1 answer
  • HELP QUICKLY!!! IF YOUR RIGHT I'LL MARK YOU BRAINLIEST
    15·2 answers
  • The Business Information Building Block feature is available in the _____ grouping on the Insert tab.
    13·1 answer
  • Meet.go ogle.etj-dovn-kds​
    14·1 answer
  • Which of these statements correctly describe aspects of testing code? Check all of the boxes that apply.
    14·1 answer
  • assuming the default gateway is connected to the internet, what type of internet access would this server have?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!