Secret code

Report a typo

John keeps a diary in a text file, but he doesn't want anybody to be able to read it except him, that's why he has decided to encode this file. You need to implement the following algorithm for encoding:

  • iterate over characters in a given string;
  • convert a character to the int value;
  • add the shift value;
  • convert the result value to string.

Sample Input 1:

Hello!
3

Sample Output 1:

Khoor$
Write a program in Go
package main

import "fmt"

func main() {
var s string
var shift int
fmt.Scan(&s, &shift)

for _, ch := range s {
fmt.Print(?) // add the shift value to the character value
}
}
___

Create a free account to access the full topic