Assuming that you have a source array that isn't abc... then you want to do it with one + one loop. I don't know why you read only 26 characters from the keyboard line. What if I have a long sentence ...
If you have a loop in a loop say for an input of 500 charaters and 26 letters, then you have 500*26/2 as the number of operations (assuming you find the letter you are after in 13 tries on average).
That is a huge overhead
So you create a mapping of a->? and b->? in another array and then
pass your input line.
You will need to get the correct look up for the array carefully done
outputLetter = newTarget[inputLetter-'a'];
Some care will also be needed on the issue of capitals and non- alphabet input, etc.
StuXYZ
Practically a Master Poster
680 posts since Nov 2008
Reputation Points: 760
Solved Threads: 138