answer.
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
leonid [27]
2 years ago
9

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 modulo 2 (remainder is either 0 or 1) Assign x with x divided by 2Note: The above algorithm outputs the 0's and 1's in reverse order.Ex: If the input is:6the output is:0116 in binary is 110; the algorithm outputs the bits in reverse.LABACTIVITY7.14.1: LAB: Convert to binary
Computers and Technology
2 answers:
neonofarm [45]2 years ago
5 0

<em>#include <stdio.h> </em>

<em>#include <stdlib.h> </em>

<em> </em>

<em>int main () </em>

<em>{ </em>

<em>    int n, i = 1, k; </em>

<em>    int j; </em>

<em>    binary int [10]; </em>

<em>    printf ("Enter Number \ t:"); </em>

<em>    scanf ("% d", & n); </em>

<em>    while (n> 0) { </em>

<em>        binary [i] = n% 2; </em>

<em>         n = n / 2; </em>

<em>         i = i + 1; </em>

<em>         k = i; </em>

<em> </em>

<em>    } </em>

<em>    for (j = k-1; j> 0; j--) </em>

<em>        { </em>

<em>        printf ("% d", binary [j]); </em>

<em>    } </em>

<em> </em>

<em>} </em>

<h2>Further explanation</h2>

Basically, what is meant by number conversion is the process of changing the form of one number to another number that still has the same value. Converting decimal numbers to binary numbers means changing the form of decimal numbers to form binary numbers that still have the same value.

The method of converting decimal numbers to binary numbers is quite easy, by dividing decimal numbers into a base of binary numbers that is 2, the results are then rounded down and the remainder of the division results are stored or recorded. Make rounding down until the value reaches zero. The remaining shares are then sorted from the last to the earliest. The rest of the sorted order is the result of the conversion of decimal numbers to binary numbers.

Example of Converting Decimal Numbers to Binary Numbers

Convert a decimal number value 50 to a binary number:

50/2 = 25 the remainder is 0

25/2 = 12 remainder is 1

12/2 = 6 the remainder is 0

6/2 = 3 remainder is 0

3/2 = 1 remainder is 1

1/2 = 0 the remainder is 1

Learn More

Simple modulo calculation program  brainly.com/question/13572257

C ++ programming language  brainly.com/question/13572257

Details

Class: College

Subject: Computers and Technology

Keywords: program, modulo, c++

MakcuM [25]2 years ago
4 0

Answer:

// Java Code

import java.io.*;  

class Binary {  

//function to convert integer to binary  

static void convert(int num)  

{  

 // array to store 32 bit binary number  

 int bin[] = new int[32];  

 int i=0,j;  

 while (num > 0) {  

  // store the remainder in the array  

  bin[i] = num % 2;  

  num = num / 2;  

  i++;  

 }    

 System.out.println("Number in Binary is");

 // Loop to print the array in reverse order

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

  System.out.print(bin[j]);  

}  

 // main method  

public static void main(String[] args)throws IOException

{  

    //Using BufferedReader class for reading input

    InputStreamReader x = new InputStreamReader(System.in);

    BufferedReader inp = new BufferedReader(x);

 int n;

 System.out.println("Enter the decimal number to convert to binary");

 n=Integer.parseInt(inp.readLine());

 convert(n);  

}  

}

Explanation:

Read an input from the user. Declare an array of size 32 to store 32 bits binary numbers. Keep dividing the input by 2 and store the remainder in the array until the number is no more divisible by 2. Now print the remainders stored in the array in reverse order.

Output:

Enter the decimal number to convert to binary

6

Number in Binary is

110

You might be interested in
A program is loaded into _________ while it is being processed on the computer and when the program is not running it is stored
erik [133]
Idkkkkkkkkkkkkkkkkkkk
4 0
2 years ago
Read 2 more answers
In which of the security mechanism does the file containing data of the users/user groups have inbuilt security?
max2010maxim [7]

Answer:

The answer is "It uses the section access with in the qlikview script".

Explanation:

QlikView is now QlikSense, it comes with section access, that protects against this danger. It a way of determining, which can display certain details, it is also known as objects, that can be displayed by whom and out of which domain, etc.

  • It can also be configured using the publishing of the company. In the data load script, users can use section access to maintain security.  
  • It uses the data for authentication and authorization within segment access and automatically decreases the information, such that users only have their information.
8 0
2 years ago
On the planet Sigma, robots excavate chunks of a very precious cristaline. These chunks can be divided into smaller part only on
Rainbow [258]

Answer:

Start the algorithm and check the weight of the ship. Load the crystalline to the ship. Check to see if the ship weighs ship weight + k pound crystalline, if less, add more crystalline. If excess, remove the excess crystalline, but if the weight meets the condition, then take off with the loaded ship to planet sigma.

Explanation:

The algorithm continuously checks the weight of the ship on loading with the calculated sum of the ship and k pound crystalline weight. The ship is able to load the correct maximum amount of crystalline to the planet sigma.

7 0
2 years ago
Into which of these files would you paste copied information to create an integrated document?
Oksanka [162]
D cause you will need to keep up with data also
7 0
2 years ago
Read 2 more answers
Write a program that creates a dictionary containing the U.S. states as keys and their capitals as values. (Use the Internet to
Dima020 [189]

Answer:

  1. import random  
  2. states = {
  3.    "Alabama": "Montgomery",
  4.    "California": "Sacramento",
  5.    "Florida": "Tallahassee",
  6.    "Hawaii": "Honolulu",
  7.    "Indiana": "Indianapolis",
  8.    "Michigan": "Lansing",
  9.    "New York": "Albany",
  10.    "Texas" : "Austin",
  11.    "Utah" : "Salt Lake City",
  12.    "Wisconsin": "Madison"
  13. }
  14. correct = 0
  15. wrong = 0
  16. round = 1
  17. while(round <= 5):
  18.    current_state = random.choice(list(states))
  19.    answer = input("What is the capital of " + current_state + ": ")
  20.    
  21.    if(answer == states[current_state]):
  22.        correct += 1
  23.    else:
  24.        wrong += 1
  25.    
  26.    round += 1
  27. print("Correct answer: " + str(correct))
  28. print("Wrong answer: " + str(wrong))

Explanation:

The solution code is written in Python 3.

Line 3 -14

Create a dictionary of US States with capital as each of their corresponding value. Please note only ten sample states are chosen here.

Line 16 - 18

Create variables to track the number of correct and inaccurate response and also round counter.

Line 19 - 28

Set the while condition to enable user to play the quiz for five questions and use random.choice to randomly pick a state from the dictionary and prompt user to input the capital of selected stated.

If the answer matched with the capital value of the selected state, increment the correct counter by one. Otherwise the wrong counter will be incremented by one. Increment the round counter by one before proceed to next round.

Line 30 - 31

Print the number of correct responses and wrong responses.

7 0
2 years ago
Other questions:
  • Given a pattern as the first argument and a string of blobs split by | show the number of times the pattern is present in each b
    14·1 answer
  • Axel is finally documenting his work. What could he be writing?
    12·1 answer
  • Consider the following network: proxy-cache On average there are 35 objects downloaded per second, and the average object size i
    14·1 answer
  • Write a program that removes all spaces from the given input.
    6·1 answer
  • To be eligible for the leadership training program offered by the office, a student must have at least 2 years of post-secondary
    9·1 answer
  • Select which type of computer you would like to begin building, based on the needs of your new job: Frequent travel Maintaining
    7·1 answer
  • Assume you have a variable, budget, that is associated with a positive integer. Assume you have another variable, shopping_list,
    11·1 answer
  • Which of the following is true of how the Internet has responded to the increasing number of devices now using the network? a) T
    12·2 answers
  • Design and implement an algorithm that gets as input a list of k integer values N1, N2,..., Nk as well as a special value SUM. Y
    12·1 answer
  • What is the function of napier's bones<br>​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!