Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C language, thanks 2. A simple way to encrypt a number is to replace each digit of the number with its position (index) in

image text in transcribed

Using C language, thanks

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 31 9 8 475 6 0. For example, 831 will be encrypted as 412 with the key array 23 19 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 "%1d" in scanf to read in a single digit into a variable (or an array element). For example, for input 101011, scanf("%1d", &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 a[], int b[l, int key[], 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 output

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

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What are the coordinates.? 2

Answered: 1 week ago