Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C language programming 2. A simple way to encrypt a number is to replace each digit of the number with its position (index) in a
C language programming
2. A simple way to encrypt a number is to replace each digit of the number with its position (index) in a key array. A key array is an ordering of the digits 0-9, such as 2 319 84 75 6 0. For example, 831 will be encrypted as 412 with the key array 2 319 84 75 6 0 because 8 is at position (index) 4 in the key array, 3 is at index 1, 1 is at index 2. Write a C program that asks the user to enter a positive integer (the integer could be of any number of digits in the range of the integer type) and encrypts the number with a key array that's randomly generated. A sample input/output: Enter the number of digits of the number: 5 Enter the number: 92028 Key array: 2 3 1 9 8 4 7 5 6 0 Output: 30904 1) Name your program encrypt.c. 2) The user will enter the total number of digits before entering the number 3) You can use format specifier "%10" in scanf to read in a single digit into a variable (or an array element). For example, for input 101011, scanf("%d", &num) will read in 1 to num. 4) Include the swap function from part 1 to generate the key array. 5) As part of the solution, write and call the function replace() with the following prototype. The replace() function assumes that the digits are stored in the array a and computes the replaced digits and store them in the array b. The function uses the key array key to encrypt. n represents the size of the array a and b. void replace(int all, int b[l, int keyll, int n); 6) The main function reads in the input and stores it in an array, calls swap function to generate the key array, and calls the replace function, and then displays the outputStep 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