|
Get 9,000+ Interview Questions with Answers in an eBook
C Source Codes List | Source Code Home
Program : Programto encrypt
/* Prg.to encrypt & decrypt a given string */
#include
# include
void main()
{
int n,i;
char a[80];
clrscr();
printf("\nEnter string:- ");
gets(a);
printf("\n\n\tOPTIONS:- ");
printf("\n(1) Encrypt the string.");
printf("\n(2) Decrypt the string.");
printf("\nCHOICE(1 or 2):- ");
scanf("%d",&n);
switch(n)
{
case 1:
for (i=0;(i<80&&a[i]!='\0');i++)
a[i]=a[i]+2;
printf("\nIts encrypted form is:- ");
printf("\n\t%s",a);
break;
case 2:
for (i=0;(i<80&&a[i]!='\0');i++)
a[i]=a[i]-2;
printf("\nIts decrypted form is:- ");
printf("\n\t%s",a);
break;
default:
printf("\nERROR.");
}
getch();
}
C Source Codes List | Source Code Home
|
|
|