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
nadezda [96]
3 years ago
8

write a c++ program that reads from the user a positive integer (in a decimal representation), and prints its binary (base 2) re

presentation. Your program should interact with the user exactly as it shows in the following example: Enter decimal number: 76 The binary representation of 76 is 1001100
Computers and Technology
1 answer:
Vesna [10]3 years ago
5 0

Answer:

The program to this question can be described as follows:

Program:

#include <iostream> //defining header file

using namespace std;

int main() //defining main method

{

int x1,rem,i=1; //defining integer variable

long Num=0;// defining long variable

cout << "Input a decimal number: "; // print message

cin >> x1; //input value by user

while (x1!=0) //loop for calculate binary number

{

//calculating binary value    

rem= x1%2;

x1=x1/2;

Num =Num +rem*i;//holding calculate value

i=i*10;

}

cout <<Num;//print value

return 0;

}

Output:

Input a decimal number: 76

1001100

Explanation:

In the above code, four variable "x1, rem, i, and Num" is declared, in which three "x1, rem, and i" is an integer variable, and one "Num" is a long variable.

  • In the x1 variable, we take input by the user and use the while loop to calculate its binary number.
  • In the loop, first, we check x1 variable value is not equal to 0, inside we calculate it binary number that store in long "Num" variable, after calculating its binary number the print method "cout" is used to prints its value.  
You might be interested in
Two categories of payroll deductions are required deductions and ___ deductions.
alukav5142 [94]

Answer:

1.)

- C.) Optional

2.)

- D.) Short-term Notes Payable

3.)

- A.) Payroll Sinking Funds

4.)

- A.) A Formal Timekeeping System Is Used

(I'm possibly wrong on the last question, if so then my apologies and I wish you the best of luck.)

3 0
2 years ago
Read 2 more answers
_____ interviews rely on scenarios and reflections to evaluate an applicant’s skill set.
ra1l [238]
I think its behavioral
4 0
3 years ago
Read 2 more answers
Compare the applications below:
Lubov Fominskaja [6]

Answer:

i think it is B

Explanation:

6 0
3 years ago
Read 2 more answers
Using a windows computer, to expand a branch of the folder tree you would _____.
s344n2d4d5 [400]
A folder can include everything from documents and music, to applications [like Word or Excel or your favorite browser]. But computer folders can also contain other folders, lots of them, and those sub-folders can contain folders of their own. This is the called folder tree. The trunk of the tree is the Desktop. Then there are several folders like Recycle Bin, Control Panel,..The most important branch is the one called ‘Libraries’. Here are the Photos, Music, Videos,...
<span>Using a windows computer, to expand a branch of the folder tree you would right click </span>beside various folders and drives to expand the folder tree.

8 0
3 years ago
What are motion graphics?
AysviL [449]
D)Animated abstract shapes
3 0
3 years ago
Other questions:
  • If you define CSS rules on a parent control, the rules will be inherited by all of the children widgets.
    12·1 answer
  • Write a for loop to verify that your function is correctly returning the expected output for the radius values between 0 and 11.
    14·1 answer
  • What does my name look like in binary code, btw my mane is Wendy Alexis Morales
    10·2 answers
  • Write a program that lets the user enter a nonnegative integer then uses a loop to calculate the factorial of that number. Displ
    11·1 answer
  • Given an initialized String variable outfile, write a statement that declares a PrintWriter reference variable named output and
    12·1 answer
  • Betty set up an account on a popular social networking website. she wants to know whether the privacy policy is effective for he
    14·1 answer
  • Convert pounds to ounces.
    11·2 answers
  • I'm not sure how to solve this problem
    12·1 answer
  • Which response best completes the following IF-ELSE statement?
    15·1 answer
  • reagan's firm has not had to make large investments in computer or networking hardware or in personnel to maintain the hardware
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!