Computer Science, asked by adityaneo, 2 days ago

Read a string and replace its every character by its consecutive character.
if word is alpha then answer should be bmqib

Answers

Answered by rajnikantsharma793
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