Question
Can anyone help me write a macro and a compte average function here? I have all the other code ready. I just need the macro
Can anyone help me write a macro and a compte average function here? I have all the other code ready. I just need the macro and the function on top. Thanks
#include
//define a MACRO COMPUTE_AVERAGE here
//define a function compute_average here
void main() { int i=1; int j=5; double ave=0.0; int num1, num2; int start_time, end_time; int time_task1, time_task2;
//reading in two integers printf("Enter an integer: "); scanf("%d", &num1); printf("Enter another integer: "); scanf("%d", &num2);
//print the results computed by MACRO and function printf("The average computed by your MACRO is: %10.2f ", COMPUTE_AVERAGE(num1, num2)); printf("The average computed by your function is: %10.2f ", compute_average(num1, num2));
//get the starting time for the MACRO start_time = clock(); printf(" start time1 %d ", start_time); while (i < 10000000) ave = COMPUTE_AVERAGE(i++, j++); // macro call
//get the ending time for the MACRO end_time = clock(); printf("end time1 %d ", end_time); time_task1 = end_time - start_time; printf("The time elapsed for the Macro is: %d ", time_task1); i = 1; j = 5;
//get the starting time for the function start_time = clock(); printf("start time %d ", start_time); while (i < 10000000) ave = compute_average(i++, j++); // regular function call
//get the ending time for the function end_time = clock(); printf("end time %d ", end_time); time_task2 = end_time - start_time; printf("The time elapsed for the regular function is: %d ", time_task2); return; }
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