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
leonid [27]
3 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]3 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]3 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
How do I delete a class on Edulastic?
GREYUIT [131]
Class>settings>remove class
hope this helps :3
4 0
4 years ago
Read 2 more answers
5 band resistor with two red bands, two gold bands, one purple band?
Mamont248 [21]

According to below picture, two gold bands on a 5 band resistor cannot happen. What is the order of the bands?

8 0
3 years ago
Peter is a data analyst in a financial firm. He maintains a spreadsheet that contains all employee details. Peter wants to analy
alukav5142 [94]

Answer: filter the data of employees with more than five years of experience

Explanation:

The technique that Peter can use to perform this analysis is to filter the data of employees with more than five years of experience.

Filter in spreadsheets allows one to see the data that is required based on the input that was given. In this case, since Peter wants to analyze the data of all employees that have experience of more than five years, this can be filtered and the employees who have experience of more than 5 years will be shown.

The workers who have experience of less than five years will not b shown in this case.

3 0
3 years ago
A boy is sitting to the side of a campfire. He is 5 feet away, but still feels warm. This is an example of:
tiny-mole [99]
This is an Conduction
8 0
3 years ago
What do you think we'll be able to do with computers in 10 years?
almond37 [142]

we would be able to put it in our pockets


6 0
3 years ago
Other questions:
  • Why do we use modem while<br>accessing the internet or email​
    10·1 answer
  • Emily wants to search online for cakes containing nuts. However, she wants to skip cakes that have raisins in them. Which option
    9·1 answer
  • With a(n) ____ the editor, compiler, and executer are combined in the same application.
    7·1 answer
  • What can be described as a measure of the amount of matter or material an object contains as well as taking gravitational pull i
    11·1 answer
  • _______ are special incentives or excitement-building programs that encourage consumers to purchase a particular product, often
    7·1 answer
  • A user prefers an external monitor, mouse, and keyboard for a laptop. The user does not want to use the built-in screen; however
    5·1 answer
  • Devon keeps his commitments, submits work when it's due, and shows up when scheduled. What personal skill does Devon
    15·2 answers
  • windows 93 it is a website THE QUESTION IS WHAT IS THE FIRST THING THAT POPS UP WHEN YOU OPEN THE WEBSITE?
    8·1 answer
  • Who is considered as the father of computer science?​
    11·1 answer
  • What is one example of the use of an infrared sensor?
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!