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
What are some advantages and disadvantages of streaming and downloading?
stepladder [879]

Answer:

Pro Cons

It is possible to download legitimate music files that do not include DRM and so makes it easier for you to listen to your tracks on different devices. The file may include DRM protection that you were not expecting when you joined the service. Read the fine print.

Explanation:

7 0
3 years ago
Security on a network not only means being able to prevent a hacker from breaking into your computer but also includes being abl
iVinArrow [24]

Security on a network not only means being able to prevent a hacker from breaking into your computer but also includes being able to recover from temporary service problems or from natural disasters is True.

a.True.

<u>Explanation:</u>

As network administrator he or she is responsible for both prevent from hacker and restore network from disaster with minimum down time. Network administrator has monitor network traffics and packets and do a period check on malware, spyware and ransom ware protection.

As network administrator should ready made tools or purchase to handle the network traffic to avoid network disaster.

Network administrator update firewall patches and upgrades virus signature files at period intervals. Network administrator also takes necessary advice from firewall hardware appliance from supplier and takes necessary steps o handle situation then and there.

7 0
4 years ago
Create a Sub called "daisyDecisions" that runs when you click a button. In this sub, you will create a program that determines w
jenyasd209 [6]

Answer:

see explaination

Explanation:

Please find the screenprint and the VBA code. As shown in the screenprint, range B1 is used to enter the number of petals. If you want to use a different cell for petals input, then change the code accordingly.

Also, the VBA code is placed in the Sheet1 module. No new modules are inserted.

Screenprint: see attachment for screenshot

VBA Code:

Private Sub CommandButton1_Click()

Call daisyDecisions

End Sub

Private Sub daisyDecisions()

Dim remainder As Integer

Dim noOfPetals As Integer

noOfPetals = Sheet1.Range("B1").Value

remainder = noOfPetals Mod 2

If remainder <> 0 Then

MsgBox "He/She loves you!!!"

Else

MsgBox "He/She loves you not!!!"

End If

End Sub

7 0
4 years ago
Int alpha [5];
Levart [38]

Answer:

D - 14

Explanation:

Each time the program executes an iteration of the for-loop, it works out the current element by adding 3 to the previous element.

alpha[0] = 2

+3

alpha[1] = 5

+3

alpha[2] = 8

+3

alpha[3] = 11

+3

alpha[4] = 14

3 0
4 years ago
A Broad Cost Leader maintains a presence in what segments?Group of answer choices
Andrew [12]

es el incisob amigo o amiga

4 0
4 years ago
Other questions:
  • Which one of the following oscilloscope controls is used to move the trace up and down the screen vertically? A. Focus B. Sweep
    9·2 answers
  • What considerations have to be kept in mind with JPEG
    10·1 answer
  • . What is the output of this code sequence?
    8·1 answer
  • Difference between query and filter<br><br>​
    12·1 answer
  • Jeanne writes a song, and Raul wants to perform
    6·2 answers
  • CRM software programs are designed to help companies gather all customer contact information into multiple data management progr
    13·1 answer
  • Which method of accessing FTP has the most limited capabilities?
    9·2 answers
  • Charts are often used in _____ to quickly represent data and help the readers understand the data.
    11·1 answer
  • Which describes the first step a crawler-based search engine uses to find information?
    10·2 answers
  • BRAINLIEST You have a small company and want to keep your costs low, but it is important your employees share data. Which networ
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!