Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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,M1] and M Output: U, where U=(xy)modM 1. U=0,V=x,A=y,P=M; 2. while A=0 do 3. If A0=1 then U=U+V;(A0= Least Significant Bit (LSB) of A) 4. If UP then U=UP; 5. A=A/2; 6. V=2V; 7. If VP, then V=VP; 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
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