-
Notifications
You must be signed in to change notification settings - Fork 0
/
Prac1.c
38 lines (36 loc) · 788 Bytes
/
Prac1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <ctype.h>
void main()
{
int i, key;
char text[100], c;
printf("Enter the plain text : ");
gets(text);
printf("Enter Key : ");
scanf("%d", &key);
for (i = 0; text[i] != '\0'; ++i)
{
c = text[i];
if (c >= 'a' && c <= 'z')
{
c = c + key;
if (c > 'z')
{
c = c - 'z' + 'a' - 1;
}
text[i] = c;
}
else if (c >= 'A' && c <= 'Z')
{
c = c + key;
if (c > 'Z')
{
c = c - 'Z' + 'A' - 1;
}
text[i] = c;
}
}
printf("Encrypted Message : %s", text);
}