Home /
Expert Answers /
Computer Science /
nbsp-referring-back-to-your-assignment-1-algorithm-and-flowchart-of-modular-multiplication-a-pa219
(Solved):
Referring back to your Assignment \#1: Algorithm and Flowchart of Modular Multiplication a ...
Referring back to your Assignment \#1: Algorithm and Flowchart of Modular Multiplication and Assignment \#5: Program Control Flow. Now create a function, named mod_mul() to compute a modular multiplication algorithm. Your C program should fulfill the following: 1. Create a header file, named mod_arith.h and declare the function prototype of mod mul(). Your function should receive three non-negative integer parameter and return a non-negative integer value according to the pseudo code. 2. Create an implementation file, named mod_arith.c to define the function body of mod_mul() as pseudo code shown below. Input : \( y, x \) ??????????? \( [1, M-1] \) and \( M \) Output: \( U \), where \( U=\left(x^{*} y\right) \bmod M \) 1. \( U=0, V=x, A=y, P=M \); 2. while \( \mathbf{A} \neq \mathbf{0} \) do 3. If \( A_{0}=1 \) then \( U=U+V_{;} \quad\left(A_{0}=\right. \) Least Significant Bit (LSB) of A) 4. If \( U \geq P \) then \( U=U-P \); 5. \( \quad \mathrm{A}=\mathrm{A} / 2 \); 6. \( \quad V=2 V \); 7. If \( V \geq P \), then \( V=V-P \); 8. Return U. 3. In your top level main.c file, use a for/while loop to call the function mod mul() multiple times by sending different parameters/arguments. The parameters/arguments could be inserted by the user or randomly generated by using srand() and rand() functions, then display the computation output. Notes: You must make sure the computation output is correct by comparing with your manual calculation as your assignment \#1. For assignment submission, you need to complete the following tasks and submit/upload few files to the e-learning: 1. .c: Source code - the main file, header files (.h) and implementation files (.c) with good programming practice) 2. .png/.jpg/: Snapshot of your program execution output.