Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hints: In macro CountBits multiply the number of bytes in the data type of its argument by the implementation-dependent number of bits in a byte.

image text in transcribed
image text in transcribed
Hints: In macro CountBits multiply the number of bytes in the data type of its argument by the implementation-dependent number of bits in a byte. In function CountIntBitsF start with a value of 1 in a type unsigned int variable and left-shift it one bit at a time, keeping count of number of shifts, until the variable's value becomes 0. If you use a plain Int (which is always signed) for this purpose you have made a portability mistake. C2A2E1 (3 points - Program) Exclude any existing source code files that may already be in your IDE project and add two new ones naming them C2A2E1_Count BitsM.h and C2A2E1_CountintBitsF.c. Also add instructor-supplied source main already exists in the code file C2A2E1 main-Driver.c. Do not write a main function! instructor-supplied file and it will use the code you write. File C2A2E1 CountBitsM.h must contain a macro named CountBitsM. CountBitsM syntax: This macro has one parameter and produces a value of type int. There is no prototype (since macros are never prototyped). Parameters: objectorType - any expression with an object data type (24. temp. printf("Hello"), etc.). or the literal name of any object data type (int, float, double, etc.) Synopsis: Determines the number of bits of storage used for the data type of objectorType on any machine on which it is run. This is an extremely trivial macro. Return: the number of bits of storage used for the data type of objectorType File C2A2E1_Countint BisF.C must contain function CountIntbits and no #define or #include. CountIntBitsi syntax: int CountIntBitsF(void); Parameters: none Synopsis: Determines the number of bits used to represent a type int value on any machine on which it is run. Return: the number of bits used to represent a type int value CountBitsM and Count IntBits must: 1. not assume a char/byte contains 8 or any other specific number of bits: 2. not call any function; 3. not use any external variables: 4. not perform any right-shifts: 5. not display anything. CountBits must: 1. not use any variables: 2. use a macro from header file limits.h CountIntBits must: 1. not use any macro or anything from any header file: 2. not be in a header file. 3. not perform any multiplications or divisions # you get an assignment checker warning regarding instructor-supplied file C2A2E1_main-Driver.c the problem is actually in your CountBits macro. Questions: If run on the same implementation could the value produced by CountBits for type int be different than the value produced by CountIntBitsFe Why or why not? The answer has nothing to do with the value CHAR BIL. Place your answers as comments in the "Title Block of file C2A2E1.Countint Bits.c

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions