Question
C program problem a: Below is some sample C code. Create the three macros indicated with comments. // Create a macro called RATE with a
C program problem
a:
Below is some sample C code. Create the three macros indicated with comments.
// Create a macro called RATE with a fixed value of 0.12
#define
// Create a macro called SIMPLE_INTEREST that takes in values principal and time
// and computes the amount of interest generated.
// Hint: simple interest is principal times rate times time (in years).
#define
// Create a macro called AMOUNT that takes in values principal and interest and
// computes the final amount after the interest has been added.
// Hint: principal plus interest.
#define
float principal = 1000.0;
int time = 10;
float simple_interest = SIMPLE_INTEREST(principal, time);
float amount = AMOUNT(principal, simple_interest);
b:
Based on the last question, write the code that would appear after the preprocessor has substituted the macros in the code:
float principal = 1000.0;
int time = 10;
float simple_interest =
float amount =
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started