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
Personality traits such as thoughtfulness, empathy, self-control, and goal orientation belong to the _____ category.
klio [65]

Answer:

C conscientiousness

Explanation:

4 0
3 years ago
Read 2 more answers
Variables used for output are associated with what controls on a form?​
NikAS [45]

Answer:

The answer to this question is given below in the explanation section

Explanation:

There are different form control. for example HTML form controls are:

  • Text Input Controls.
  • Checkboxes Controls.
  • Radio Box Controls.
  • Select Box Controls.
  • File Select boxes.
  • Hidden Controls.
  • Clickable Buttons.
  • Submit and Reset Button.

Variables used for output are associated with text input and label control on a form.

For example, if you want to show the name of the user that is stored in a variable <em>name</em>. Then you want to output the <em>name</em> on a form, for this, you need to associate this variable with label or text input control

8 0
3 years ago
Impaired drivers not only harm themselves but they harm other individuals and affect our _________________.
lawyer [7]

entire society. impaired drivers affect all of those things.

4 0
4 years ago
Read 2 more answers
Which of these devices features D-pads and analog sticks?
r-ruslan [8.4K]

B. Portable consoles feature D-pads and analog sticks on their controllers

8 0
3 years ago
Fwee Pwoints Fwor You! :3
Fittoniya [83]

Answer:

Hey thanks for them........

8 0
3 years ago
Read 2 more answers
Other questions:
  • According to the partnership for 21st-century learning critical thinking ability includes all the following skills except
    15·1 answer
  • Which of the following tasks would you most likely use a spreadsheet to complete
    15·1 answer
  • Read the excerpt from The Code Book. Other attacks include the use of viruses and Trojan horses. Eve might design a virus that i
    13·1 answer
  • What does the somaliland high population density <br>​
    15·1 answer
  • Which database item would show details such as a customer’s name, their last purchase, and other details about a customer?
    11·2 answers
  • Your program will search for prime numbers. You will first ask the user for the range of values to search, and use for loops to
    6·1 answer
  • 2.cite at least 2 example on how multimedia facilitates learning​
    6·1 answer
  • You learned that you can use the tags to insert a link to another webpage. One problem that webpage developers face is that, aft
    10·1 answer
  • Re:
    15·1 answer
  • Which of the following tiny computer apps is designed to be useful but could cause more harm than good?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!