1#include<iostream>
2
3using namespace std;
4
5int main()
6{
7char message[100], ch;
8int i, key;
9cout << "Enter a message to encrypt: ";
10cin.getline(message, 100);
11cout << "Enter key: ";
12cin >> key;
13for(i = 0; message[i] != '\0'; ++i){
14ch = message[i];
15if(ch >= 'a' && ch <= 'z'){
16ch = ch + key;
17if(ch > 'z'){
18ch = ch - 'z' + 'a' - 1;
19}
20message[i] = ch;
21}
22else if(ch >= 'A' && ch <= 'Z'){
23ch = ch + key;
24if(ch > 'Z'){
25ch = ch - 'Z' + 'A' - 1;
26}
27message[i] = ch;
28}
29}
30cout << "Encrypted message: " << message;
31return 0;
32}
33