Question: We are meant to define a data dictionary and the encoding/decoding logic in flowchart format for this c++ code. The user enters a number with
We are meant to define a data dictionary and the encoding/decoding logic in flowchart format for this c++ code.
The user enters a number with characters of 2 to 8. If the number is a two digit number you swap the positions of the numbers (eg: if the number is 56, altered number is 65). 2. If the number is a three digit number, digits at positions 1 and 3 are swapped. (eg: number is 123, altered number is 321) 3. If the number is four digits or above the following rules apply. Replace the first digit by the remainder after the sum of that digit plus 1 is divided by 10, the second digit by the remainder after the sum of that digit plus 2 is divided by 10, third digit by the remainder after the sum of that digit plus 3 is divided by 10, fourth digit by the remainder after the sum of that digit plus 4 is divided by 10 and so on.
can I have a couple of lines filled in this data table as I still don't understand it. and the encoding logic from the code in flowchart format?

#include //input output
#include //sleep function
using namespace std; //used for ease of typing
void encrypt(int array[], int digit) //encrypt contains integer array and (integer)
{
for(int i=0; i
{
array[i] = (array[i] + digit - i)%10; //decrypt algorithm = (number - digit - array_value) mod(%) 10
}
}
void decrypt(int array[], int digit)
{
for(int i=0; i
{
array[i] = (array[i] - digit + i + 10)%10; //encrypt algorithm = (number + digit + array_value + 10) mod(%)10
}
}
int numberOfDigit(int number)
{
int digit = 0;
while(number)
{
digit++;
number = number/10;
}
return digit;
}
int main()
{
cout
int number;
cin>>number;
int digit = numberOfDigit(number);
if(digit 8)
{
cout
}
int maxDigit = 8;
int array[maxDigit] ={0};
int i = digit-1;
while(number)
{
array[i] = number%10;
number = number /10;
i--;
}
cout
encrypt(array, digit);
sleep(2);
cout
sleep(1);
cout
sleep(1);
cout
sleep(1);
cout
for(int i=0; i
{
cout
}
cout
cout
decrypt(array,digit);
sleep(2);
cout
sleep(1);
cout
sleep(1);
cout
sleep(1);
cout
for(int i=0; i
{
cout
}
cout
}
thank you in advance :)
Position of the number is counted from right to left. 5 Position 8 9 Position 7 1 5 4 2 Position 3 3 Position 2 9 Position 1
Step by Step Solution
3.43 Rating (153 Votes )
There are 3 Steps involved in it
encrytion decryption DATA to be stored Sample data Type of data C type input method output ... View full answer
Get step-by-step solutions from verified subject matter experts
