Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A string is an array of characters. Each character is represented by an integer. The number that represents the character A is 65, the number

image text in transcribed

A string is an array of characters. Each character is represented by an integer. The number that represents the character "A" is 65, the number for "B" is 66, and so on. You can convert a string to an array of numbers (or a single character to a single number) by using the abs function or by performing an arithmetic operation involving a number, e.g. 'A' + 3 (which gives the result, 68). You can convert an array of numbers to a string (or a single number to a single character) using the char function. The mod function can be used to wrap numbers around to zero when they become too large (note: mod (am) returns a value between 0 and m-1, inclusive). The function upper converts a string to uppercase. Now it's your turn. Write a function (caesak.m) that takes as input two arguments: a string to encrypt and the key (shift value), and outputs a single argument which is a string containing the Caesar cipher encryption of the given string using the given key. The key may be positive (right shift) or negative (left shift). Your function should force the input to be uppercase and you should delete spaces and punctuation2. Example: ca'hello world', 3) KHOORZRUOG

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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