0

Encryption : Rotate 3

i want to transform a letter from the alphabet to another one ( that other one is the letter who's after the first letter by 3) e.g. letter 'a' becomes 'd' and 'b' becomes 'e'... i do have an idea for how to do this but instead of the letter being transformed to the letter i only get the ascii code of that number... any help will be appreciated!

11th Dec 2016, 6:28 PM
Bourhan Dernayka
Bourhan Dernayka - avatar
3 Réponses
+ 1
because probably u r not casting . suppose ur character is 'a' then u should weite simply 'a' +3 for d but here u r doing one mistake. as 3 is int whole expression will get coverted to ascii /int value of d. to make it character again typecast it like (char)('a'+3)
11th Dec 2016, 7:02 PM
manish rawat
manish rawat - avatar
+ 1
thanks mate it worked :)
11th Dec 2016, 7:08 PM
Bourhan Dernayka
Bourhan Dernayka - avatar
+ 1
bro i dont know c#😞 but i suggest u one thing write - (char)(ch+(3+ch-'a' )%26 ); this one line will shorten ur code
11th Dec 2016, 7:31 PM
manish rawat
manish rawat - avatar