Programing C Just with #include Calculate Binary Number Given a number, your program will calculate its binary equivalent. As shown in the figure below, your program will ask the user for a number, then print out the resulting binary. Guidelines: • First, scan the number in your main function. • Next, from main, send this number to function aaa and determine how many binary digits you will need to represent the decimal number in binary. In other words, if the user inputs 26, how many times can you divide 26 by 2 and keep dividing it by two until you reach 0? In the representation below, I show that I needed 5 divisions for 26 to reach 0 (notice I ignored the 0.5 for 6, 1 and 0). 26 = 13 → 2 13 6. 3 = 3 → 2 Using this logic, you should be able to determine how many binary digits you will need for any decimal number the user gives you. Once your function determines the number of binary digits that you will need, it should return this value back to main. • Then, in main, you will call function bbb. You will send two values, the number of digits determined in function aaa and the decimal number inputted by the user. Then, you will create a temporary array; can you guess what its length will be? • Once you declare your temporary array, you will use it to store the remainders of your divisions (do you remember the process of converting from decimal to binary?). To do so, you will need the modulo operator.. • If we look at the example of 26 in the figure below, we can see that its binary number is 11010. Well, at the end of function bbb your array should be the exact opposite of this binary number. At the end of function bbb, the values inside your array should be 01011. Thus, you will need a third function (function ccc), to which you will send this array and print the values backwards. Notice that you will also have to send the length of your array to function ccc. • Functions bbb and ccc should not return anything. What is your decimal number? 26 We will need 5 binary digits. Decimal Number is: 26 Binary Number is: 11010 What is your decimal number? 81 We will need 7 binary digits. Decimal Number is: 81 Binary Number is: 1010001 What is your decimal number? 103 We will need 7 binary digits. Decimal Number is: 103 Binary Number is: 1100111

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Programing C
Just with #include<stdio.h>
Calculate Binary Number
Given a number, your program will calculate its binary equivalent. As shown in the figure below, your program
will ask the user for a number, then print out the resulting binary.
Guidelines:
• First, scan the number in your main function.
• Next, from main, send this number to function aaa and determine how many binary digits you will need to
represent the decimal number in binary. In other words, if the user inputs 26, how many times can you divide 26
by 2 and keep dividing it by two until you reach 0? In the representation below, I show that I needed 5 divisions
for 26 to reach 0 (notice I ignored the 0.5 for 6, 1 and 0).
26
= 13 →
2
13
6.
3
= 3 →
2
Using this logic, you should be able to determine how many binary digits you will need for any decimal number
the user gives you. Once your function determines the number of binary digits that you will need, it should
return this value back to main.
• Then, in main, you will call function bbb. You will send two values, the number of digits determined in
function aaa and the decimal number inputted by the user. Then, you will create a temporary array; can you
guess what its length will be?
• Once you declare your temporary array, you will use it to store the remainders of your divisions (do you
remember the process of converting from decimal to binary?). To do so, you will need the modulo operator..
• If we look at the example of 26 in the figure below, we can see that its binary number is 11010. Well, at the
end of function bbb your array should be the exact opposite of this binary number. At the end of function bbb,
the values inside your array should be 01011. Thus, you will need a third function (function ccc), to which you
will send this array and print the values backwards. Notice that you will also have to send the length of your
array to function ccc.
• Functions bbb and ccc should not return anything.
What is your decimal number? 26
We will need 5 binary digits.
Decimal Number is: 26
Binary Number is: 11010
What is your decimal number? 81
We will need 7 binary digits.
Decimal Number is: 81
Binary Number is: 1010001
What is your decimal number? 103
We will need 7 binary digits.
Decimal Number is: 103
Binary Number is: 1100111
Transcribed Image Text:Programing C Just with #include<stdio.h> Calculate Binary Number Given a number, your program will calculate its binary equivalent. As shown in the figure below, your program will ask the user for a number, then print out the resulting binary. Guidelines: • First, scan the number in your main function. • Next, from main, send this number to function aaa and determine how many binary digits you will need to represent the decimal number in binary. In other words, if the user inputs 26, how many times can you divide 26 by 2 and keep dividing it by two until you reach 0? In the representation below, I show that I needed 5 divisions for 26 to reach 0 (notice I ignored the 0.5 for 6, 1 and 0). 26 = 13 → 2 13 6. 3 = 3 → 2 Using this logic, you should be able to determine how many binary digits you will need for any decimal number the user gives you. Once your function determines the number of binary digits that you will need, it should return this value back to main. • Then, in main, you will call function bbb. You will send two values, the number of digits determined in function aaa and the decimal number inputted by the user. Then, you will create a temporary array; can you guess what its length will be? • Once you declare your temporary array, you will use it to store the remainders of your divisions (do you remember the process of converting from decimal to binary?). To do so, you will need the modulo operator.. • If we look at the example of 26 in the figure below, we can see that its binary number is 11010. Well, at the end of function bbb your array should be the exact opposite of this binary number. At the end of function bbb, the values inside your array should be 01011. Thus, you will need a third function (function ccc), to which you will send this array and print the values backwards. Notice that you will also have to send the length of your array to function ccc. • Functions bbb and ccc should not return anything. What is your decimal number? 26 We will need 5 binary digits. Decimal Number is: 26 Binary Number is: 11010 What is your decimal number? 81 We will need 7 binary digits. Decimal Number is: 81 Binary Number is: 1010001 What is your decimal number? 103 We will need 7 binary digits. Decimal Number is: 103 Binary Number is: 1100111
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education