Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit df61a25

Browse files
author
Simranjit kaur
committed
error
1 parent 4170a2b commit df61a25

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Autor : Nemonet TYP
2+
// Title: Encryption and Decryption project in C++
3+
// PROJECT FOR C/C++ PROGRAMMING TUTORIAL
4+
5+
6+
#include <iostream>
7+
using namespace std;
8+
9+
int main()
10+
{
11+
int i, x;
12+
char str[100];
13+
14+
cout << "Please enter a string:\t";
15+
cin >> str;
16+
17+
cout << "\nPlease choose following options:\n";
18+
cout << "1 = Encrypt the string.\n";
19+
cout << "2 = Decrypt the string.\n";
20+
cin >> x;
21+
22+
//using switch case statements
23+
switch(x)
24+
{
25+
//first case for encrypting a string
26+
case 1:
27+
for(i = 0; (i < 100 && str[i] != '\0'); i++)
28+
str[i] = str[i] + 2; //the key for encryption is 3 that is added to ASCII value
29+
30+
cout << "\nEncrypted string: " << str << endl;
31+
break;
32+
33+
//second case for decrypting a string
34+
case 2:
35+
for(i = 0; (i < 100 && str[i] != '\0'); i++)
36+
str[i] = str[i] - 2; //the key for encryption is 3 that is subtracted to ASCII value
37+
38+
cout << "\nDecrypted string: " << str << endl;
39+
break;
40+
41+
default:
42+
cout << "\nInvalid Input !!!\n";
43+
}
44+
return 0;
45+
}

0 commit comments

Comments
 (0)