Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please Complete in Ubuntu in VirtualBox 1. Create a file, gcd.h, with the following function prototype: int gcd( int x, int y ); Also make

image text in transcribedimage text in transcribed

Please Complete in Ubuntu in VirtualBox

1. Create a file, gcd.h, with the following function prototype: int gcd( int x, int y ); Also make sure it has any necessary code for making sure that the file can't be included multiple times by a same program file (the \#ifndef, \#define, and \#endif combination you should have learned in C class). 2. Create a file, gcd.c, with the implementation of the function. If x and y are given as arguments, it should return the greatest common denominator of the two integers, or 1 if one or more of the arguments are invalid (i.e. less than or equal to zero). 3. Create a file, utilities.h, with two defined macros in it: EXIT_ON_VALUE(expression, value, message, exit_status) - if the expression is equal to the value, it should print the message to stderr, and exit the program with the given exit status. RETURN_AND_FREE_ON_VAL(expression, value, return_value, free1, free2, free3) - if the expression is equal to the value, it should free each of the three values (free1, free2, and free3) if they are not already NULL, and then return the given return_value. They need to be implemented as macros, not functions. While it seems odd now, such sorts of macros can save a lot of time and code clutter later. Also make sure it has any necessary code for making sure that the file can't be included multiple times by a same program file (the \#ifndef, \#define, and \#endif combination you should have learned in C class). 4. Create a file, main.c, that has the following code: \#include \#include 5. A makefile, called 'Makefile' (note the capital M). It should be defined so that when 'make' is run, it should compile a program 'calculate_gcd' using the C code described above. When 'make clean' is run, it should remove the compiled 'calculate_gcd' program if it exists, and should also remove any compiled object files (.o files) if they exist. Important: I know some people might have taken a class where makefiles were used to also run your program and put together its output with the code. Don't do that. People don't do that with make. The markers should be able to test your program and then clean it up by running something like: make //calculate_gcd 2048 //calculate_gcd 28126 //calculate_gcd 128362 //calculate_gcd //calculate_gcd 7 //calculate_gcd-1217 //calculate_gcd - 124 make clean

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

Database Publishing With Filemaker Pro On The Web

Authors: Maria Langer

1st Edition

0201696657, 978-0201696653

More Books

Students also viewed these Databases questions

Question

Draw the inverse of f (x), shown at right?

Answered: 1 week ago