Q:

In cryptography, the intended message sometimes consists of the first letter of every word in a string

0

 In cryptography, the intended message sometimes consists of the 

first letter of every word in a string. Write a function crypt that will 

receive a string with the encrypted message and return the message.

>> estring = 'The early songbird tweets';

>> m = crypt(estring)

m =

Test

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

crypt.m

function message = crypt(instring);

% This function returns the message hidden in the

% input string, which is the first letter of

% every word in the string

% Format crypt(input string)

% Returns a string consisting of the first letter

% of every word in the input string

rest = strtrim(instring);

message = '';

while ~isempty(rest)

 [word, rest] = strtok(rest);

 message = strcat(message,word(1));

end

end

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now