encrypt message in c

Solutions on MaxInterview for encrypt message in c by the best coders in the world

showing results for - "encrypt message in c"
Juan David
25 Jul 2017
1// Encryption : A is replaced by B, B is replaced by C and Z is replaced by A
2
3#include <stdio.h>
4#include <string.h>
5void main()
6{
7    char arr[100];
8    int i;
9
10    printf("Enter the array: ");
11    gets(arr);
12
13    for(i=0; i<strlen(arr); i++)
14    {
15        if (arr[i]>=65 && arr[i]<90)
16            arr[i] = arr[i] + 1;
17
18        else if (arr[i]>=97 && arr[i]<122)
19            arr[i] = arr[i] + 1;
20
21        else if (arr[i] == 90)
22             arr[i] ='A';
23
24        else if (arr[i] == 122)
25             arr[i] ='a';
26
27        else
28            printf("enter characters");
29    }
30
31    printf("\nEncrypted message is: \n\n");
32
33    puts(arr);
34}
35