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
Nezavi [6.7K]
4 years ago
12

8.10 LAB: Convert to binary - functions Write a program that takes in a positive integer as input, and outputs a string of 1's a

nd 0's representing the integer in binary. 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:
Korvikt [17]4 years ago
3 0

Answer:

// This program is written in C++ programming language

// Comments are used for explanatory purpose

// Program starts here

#include <iostream>

#include <string>

using namespace std;

// Declare variables

int inputvar;

// Declare output variable as array

int outputvar[32];

// Set a counter for binary array

int i = 0;

while (inputvar > 0) {

// Divide inputvar by 2 and store remainder in outputvar

outputvar[i] = n % 2;

inputvar/=2;

i++; // increment i by 1

}

// End of division

// Prin resulting array in reverse order

for (int j = i - 1; j >= 0; j--) {

cout << outputvar[j];

}

return 0;

}

// End of Program

You might be interested in
What is the simplest way to permanently get rid of an unwanted file? A. Cancel the file. B. Go to the Start menu and then delete
Morgarella [4.7K]
Go to the Start menu and then delete the file <span>is the simplest way to permanently get rid of an unwanted file</span>
5 0
4 years ago
Describe a situation when you would use a conditional statement in a program. Describe the action that would occur when the cond
kramer

Answer:  Conditional statements are just true false statements

Explanation:

Let's say there's a kpop band burglarizing my house and I have a super AI that detects if a kpop band is my house through cameras. What it would do is change a variable "kpopBandInHouse = False" to True. I would then have an if statement next with a custom function:

if kpopBandInHouse == True:

   nukeHouse()

So if the conditional statement is true, it nukes my house. It is false, it does not nuke my house.

7 0
3 years ago
Explain three ways you can get home safely if the friend you rode with has drugs or alcohol in his or her system and you prevent
Lelu [443]
You could organised to be picked up, call a taxi or a sober peer or take public transport.
7 0
4 years ago
You work as a network technician for uCertify Inc. You have erased data saved in your laptop. You still have many device configu
zloy xaker [14]

Answer:

Data remanence

Explanation:

Data remanence is the retention of erased data on a magnetic medium. Sensitive detection systems can pick up the residue (remnants) from previously recorded data even though the area has been rewritten.

This is not a simple procedure; however, it is employed if the <u>missing information</u> is related to national defense or some other critical situation

7 0
3 years ago
Identify the subject: Computer graphics are amazing these days.
Shtirlitz [24]
B.................................
3 0
4 years ago
Read 2 more answers
Other questions:
  • Which three phrases describe a wireframe
    12·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    9·1 answer
  • Explain what might happen if two stations are accidentally assigned the same hardware address?
    15·1 answer
  • The Python MySQL Connector library:
    15·1 answer
  • In 2-3 sentences, explain to another student why shortcuts are beneficial. Include details about shortcuts that you have used.
    10·2 answers
  • Which componet is the smallest unit in a spreadsheet
    15·1 answer
  • What is MS-Word? Write some versions of MS-Word.
    8·2 answers
  • What is the output?<br> str = 'abcdef<br> print(str[2:50)
    6·2 answers
  • True or false: If you have a 32-bit CPU architecture, it's recommended to use a 64-bit operating system.
    14·1 answer
  • Write a pseudocode to read 10 integer numbers and find the largest number, you need to use loop in your answer.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!