Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 //this is to call printf() function to put output #include //this is to call clock() function that get the time

//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

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_2

Step: 3

blur-text-image_3

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

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions

Question

List four rights of the shareholders

Answered: 1 week ago