Q:

Using the functions char and double, one can shift words. For example, one can convert from lower case to upper case by subtracting 32 from the character codes:

0

Using the functions char and double, one can shift words. For 

example, one can convert from lower case to upper case by 

subtracting 32 from the character codes:

>> orig = 'ape';

>> new = char(double(orig)-32)

new =

APE

>> char(double(new)+32)

ans =

ape

We’ve “encrypted” a string by altering the character codes. Figure out 

the original string. Try adding and subtracting different values (do this 

in a loop) until you decipher it:

Jmkyvih$mx$syx$}ixC

All Answers

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

Ch7Ex26.m

% Loop to decipher the code

code = 'Jmkyvih$mx$syx$}ixC';

code = char(double(code)-1);

disp(code)

choice = input('Enter ''c'' to continue: ','s');

while choice == 'c'

 code = char(double(code)-1);

 disp(code)

 choice = input('Enter ''c'' to continue: ','s');

end

>> Ch7Ex26

Iljxuhg#lw#rxw#|hwB

Enter 'c' to continue: c

Hkiwtgf"kv"qwv"{gvA

Enter 'c' to continue: c

Gjhvsfe!ju!pvu!zfu@

Enter 'c' to continue: c

Figured it out yet?

Enter 'c' to continue: yes

>>

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