Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

Do not modify any part of this program that you are given. Doing so may cause you to fail automated test cases. // You are given a partially complete program. Your job is to complete the functions in order for this program to work successfully. // All instructions are given above the required functions, please read them and follow them carefully.

#pragma warning(disable : 4996)

// Read before you start:
// Do not modify any part of this program that you are given. Doing so may cause you to fail automated test cases.
// You are given a partially complete program. Your job is to complete the functions in order for this program to work successfully.
// All instructions are given above the required functions, please read them and follow them carefully.
// If you modify the function return types or parameters, you will fail the automated test cases.
// You can assume that all inputs are valid. Ex: If prompted for an integer, an integer will be input.

// Forward Declarations
void encryption(char[], int);
void decryption(char[], int);
void sortStrings(char[5][32]);
void matrix(int[50][50]);
void printMultiplicationTable(int[50][50], int);

// Problem 1: (5 points)
// In order to encrypt the input array of characters, we will shift those characters forward alphabetically by the integer value ‘e’
// If the input string is “hello” and e = 2, we will shift those characters forward alphabecially by 2 and the result will be “jgnnq”
// Hint: Use strlen() to find the amount of characters in the array
void encryption(char input[], int e)
{
int len = strlen(input);

for (int i = 0; i {
char chr = input[i];

if (chr == ‘z’)
chr = ‘a’;
else chr = chr + e;

input[i] = chr;

}
}

// Problem 2: (5 points)
// In order to decrypt the input array of characters, we will shift those characters backwards alphabetically by the integer value ‘d’
// If the input string is “jgnnq” and d = 2, we will shift those characters back alphabecially by 2 and the result will be “hello”
// Hint: this should be very similar to your encryption function
void decryption(char input[], int d)
{
int len = strlen(input);

for (int i = 0; i {
char chr = input[i];

if (chr == ‘z’)
chr = ‘a’;
else chr = chr – d;

input[i] = chr;
}
}

// Problem 3: (5 points)
// Swap the strings that are passed as parameters, this function will be used in Problem 4.
// If string1 is “hello” and string2 is “goodbye”, after calling this function, string1 will be “goodbye” and string2 will be “hello”.
void swapStrings(char string1[], char string2[])
{
char arrayswap[32];
strcpy(arrayswap, string1);
strcpy(string1, string2);
strcpy(string2, arrayswap);

}

// Problem 4: (20 points)
// Use the selection sort algorithm to alphabetically sort the strings in the 2D character array “strings”.
// If you are unfamiliar with selection sort, here is a visual example: https://en.wikipedia.org/wiki/Selection_sort
// NOTE: ‘A’ and ‘a’ should be considered alphabetically equivalent.
// NOTE: You MUST use the selection sort algorithm for your program to produce the correct output.
// NOTE: You MUST incorporate your “swapStrings” function to recieve full points for this part.
// See output provided in word document for example input and output.
void sortStrings(char strings[5][32])
{

}

// Problem 5: (10 points)
// Using the 2D integer array “input”, you are to fill the array with a multiplication table for the integer “num”
// For example: if num = 2, your output 2D array should contain:
// input[0][0] = 1
// input[0][1] = 2
// input[1][0] = 2
// input[1][1] = 4
// See output provided in word document for further clarification
void multiplicationTable(int input[50][50], int num)
{

}

// Problem 6: (5 points)
// Print the 2D array in the following format:
// 12
//24
// Use ‘t’ to print a tab after each index and ‘n’ to print a newline after each line
// Hint: this should be very similar to your multiplicationTable function
// See ouptut provided in word document for further clarification
void printMultiplicationTable(int input[50][50], int num)
{

}

// You should study and understand how this main function works.
// Do not modify it in any way, there is no implementation needed here.
void main()
{
int selection; // used for program selection

char input[32]; // used for encryption
int encrypt; // used for encryption

char strings[5][32]; // used for sorting

int num; // used for multiplication table
int mt[50][50]; // used for multiplication table

printf(“Select one of the following:n”); // prompt for program selection integer
printf(“1: Encryptionn”);
printf(“2. Sortingn”);
printf(“3. Multiplication Tablen”);
scanf(“%d”, &selection); // store program selection integer

getchar(); // consume ‘n’ char; NOTE: If you are using GCC, you may need to comment out this line
printf(“n”); // newline

switch (selection)
{
case 1:

printf(“Enter a string up to 20 characters long: “); // prompt for string
fgets(input, sizeof(input), stdin); // store string
input[strlen(input) – 1] = ”; // discard ‘n’ char; NOTE: If you are using GCC, you may need to comment out this line

printf(“Enter an Integer value for Encryption: “); // prompt for integer
scanf(“%d”, &encrypt); // store integer

encryption(input, encrypt); // encrypt string
printf(“nEncrypted String: %sn”, input); // print encrypted string

decryption(input, encrypt); // encrypt string
printf(“Decrypted String: %sn”, input); // print decrypted string

break;

case 2:

printf(“Enter the first String: “); // prompt for string
fgets(strings[0], sizeof(strings[0]), stdin); // store string

printf(“Enter the second String: “);
fgets(strings[1], sizeof(strings[1]), stdin);

printf(“Enter the third String: “);
fgets(strings[2], sizeof(strings[2]), stdin);

printf(“Enter the fourth String: “);
fgets(strings[3], sizeof(strings[3]), stdin);

printf(“Enter the fifth String: “);
fgets(strings[4], sizeof(strings[4]), stdin);

sortStrings(strings); // call sorting function

// print strings in sorted order
printf(“nSorted Strings:n%s%s%s%s%s”, strings[0], strings[1], strings[2], strings[3], strings[4]);

break;

case 3:

printf(“Enter an integer 1-50 for a multiplication table: “); // prompt for integer
scanf(“%d”, &num); // store integer

multiplicationTable(mt, num); // create multiplication table
printf(“n”); // newline
printMultiplicationTable(mt, num); // print multiplication table

 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"