Read a string and replace its every character by its consecutive character.
if word is alpha then answer should be bmqib
Answers
Answered by
1
Answer:
Given string str consisting of lowercase letters only and an integer k, the task is to replace every character of the given string with a character whose ASCII value is k times more than it. If the ASCII value exceeds ‘z’, then start checking from ‘a’ in a cyclic manner.
Examples:
Input: str = “abc”, k = 2
Output: cde
a is moved by 2 times which results in character c
b is moved by 2 times which results in character d
c is moved by 2 times which results in character e
Input: str = “abc”, k = 28
Output: cde
a is moved 25 times, z is reached. Then 26th character will be a, 27-th b and 28-th c.
b is moved 24 times, z is reached. 28-th is d.
b is moved 23 times, z is reached. 28-th is e.
Similar questions
Accountancy,
1 day ago
Accountancy,
1 day ago
Math,
2 days ago
Math,
2 days ago
Social Sciences,
8 months ago
Social Sciences,
8 months ago