(3) Write a function that will print an integer in binary format. HINT: start at the highest order bit, which for a 4-by

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

(3) Write a function that will print an integer in binary format. HINT: start at the highest order bit, which for a 4-by

Post by answerhappygod »

3 Write A Function That Will Print An Integer In Binary Format Hint Start At The Highest Order Bit Which For A 4 By 1
3 Write A Function That Will Print An Integer In Binary Format Hint Start At The Highest Order Bit Which For A 4 By 1 (12.45 KiB) Viewed 37 times
In C please, Thank you
(3) Write a function that will print an integer in binary format. HINT: start at the highest order bit, which for a 4-byte integer would be bit 31. Mask off that bit (see if it is a 0 or 1), then print out either a 0 or 1 accordingly. Decrement bitnum until all bits have been printed out (while bitnum is greater than or equal to zero). void PrintBinary(int value){ printf("0b"); // prefix with Ob // if sizeof(int) ==4, starts at bit 31 int bitnum = sizeof(int) 8 - 1;
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply