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
Marysya12 [62]
3 years ago
12

write a program that convert binary number to decimal. I mean the input should be binary number and the output decimal number!!.

Computers and Technology
1 answer:
wolverine [178]3 years ago
8 0

Answer:

#include<iostream>

#include<math.h>

using namespace std;

//main function

int main(){

   //initialization

   long b1;

   int d1=0,count_pos=0;

//display the message

   cout<<"Enter the binary number: ";

   cin>>b1;  //store the value

   //loop for take the digit one by one

   while(b1!=0){

       int rem1 = b1%10;

       d1 = d1 + rem1*pow(2,count_pos);

       count_pos++;

       b1 = b1/10;

   }

   //display the output

   cout<<"The decimal number is: "<<d1<<endl;

}

Explanation:

Create the main function and initialize the variables. Then, display the message on the screen by using the instruction cout and then, store the input enter by the user into the variable. Here, the variable declares with type 'long' because of the size of the input.

After that, we take a while loop for splitting the binary number into the digits and then we can do the operation.

Let's understand how you can convert binary to decimal with an example:

let the binary number is 1001:

decimal number is [tex]1*2^{3}+0*2^{2}+0*2^{1}+1*2^{0}=9[/tex]

we put the same algorithms in the code. split the number into digit and then multiply with n raised to the power of 2 here, n is the position of digit from left to right.

NOTE: Position starts from zero.

and then, add the values. this process continues until the number is not zero.

After that, display the output on the screen.

You might be interested in
Need help ASAP <br><br> Thankss + BRAINLIST only for correct answers
AVprozaik [17]
Why visit it?
For entertainment, purely for the user to enjoy the content that has been produced for them.

Why was it made?
Netflix is a subscription based service that has been made to allow users to stream TV shows and other entertainment sources. It was made for leisure.
7 0
3 years ago
How to make a Tip Calculator in code?
ki77a [65]
You should have the percentage of tip based on the service that you received.
Then you multiply the percentage of tip by the amount of money that you have to pay for what you bought.
4 0
3 years ago
Net neutrality refers to the idea that Internet service providers (ISPs), including cable Internet and wireless carriers, should
Vedmedyk [2.9K]

Answer:

True is the right answer.

Explanation:

The term net neutrality can be defined as the principle which states that all internet service providers treat all communication channels i.e wired or wireless channels equally.

In net neutrality, there can not be any discrimination on the basis of the website, user, protocol, hardware or application.

In net neutrality, the internet service provider can not charge the user on the basis of some specific content.

Hence the most appropriate answer is true.

8 0
3 years ago
Read 2 more answers
Question 7 of 25
Vika [28.1K]

Explanation:

the right answer may be A.

5 0
2 years ago
In which of the following scenarios would you choose to embed versus import data?
Mrrafil [7]

Answer:

B.)You want to maintain connections with external files

Explanation:

These are the options for the question

A.)You do not want to save the original data sources.

B.)You want to maintain connections with external files

C.)You want to reduce file size

Embedding data can be regarded as insertion of objects( embedded object) such as spreadsheet into a word-processor so that it can be edditted.

Data Import can be regarded as ways that give room for uploading of data

from external sources , then combine it with data that is been collected via Analytics.

6 0
3 years ago
Other questions:
  • Richman Investments is an investment and consulting firm. Richman wants to expand its business operations both in the U.S. and i
    14·1 answer
  • What is computing networking​
    5·1 answer
  • Which of these automotive repair areas helps the vehicle change speeds to operate efficiently under all conditions?
    5·1 answer
  • What is a method whereby new problems are solved based on the solutions from similar cases solved in the past?
    9·1 answer
  • The computer mouse is used to
    11·1 answer
  • Is a plotter input output or both
    10·1 answer
  • Annie needs to provide a form field that will allow users to select from a predefined list of options but without the ability to
    8·1 answer
  • 50 POINTS How do you express yourself and your creativity through computer science?
    12·1 answer
  • Which heading size fits for the word headings​
    9·2 answers
  • PLS HURRRYYYYYY!1!1!1!1!1
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!