Exercise 1 Write a C program named lab1.c that implements a function named mod() that accepts two integer variables as input arguments and returns the
Exercise 1 Write a C program named lab1.c that implements a function named mod() that accepts two integer variables as input arguments and returns the remainder of the integer division between the first and second input arguments. This function must not use the built-in (%) operator. You must instead implement the logic using the division (/), subtraction (-), and multiplication (*) operators. Your lab1.c program must also implement a second function named Convert2Binary() that accepts an integer argument as input and prints the binary representation of the input argument onto the console screen using a recursive algorithm. The return type for this function must be specified as void. Requirements Your submission must meet the following requirements for full credit: 1. It must be a single C source file named lab1.c. Please do not submit files with other extensions. 2. Your program must compile and execute without error.
3. Function mod() must not use the built-in (%) operator. 4. Function Convert2Binary() must use a recursive algorithm (i.e., it must call itself). Furthermore, the return type for this function must be specified as void. 5. Functions mod() and Convert2Binary() must both be implemented after the main() function in your program. This means thar you must provide their prototype before the main() function. 6. You must include the following main() function in your lab1.c program int main() { printf("The base 2 representation of 112 is: "); Convert2Binary(112); printf(" "); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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