#include<iostream.h>
#include<conio.h>
void encrypt(char *ch);
void decrypt(char *ch);
void main()
{
                char str[500];
                clrscr();
                cout<<"Enter The Message : ";
                cin.getline(str,500);
                encrypt(str);
                cout<<"\nThe Encrypted Message : "<<str<<endl;
                decrypt(str);
                cout<<"\nThe Decrypted Message : "<<str<<endl;
                getch();
}
void encrypt(char *ch)
{
                int i=0;
                while(ch[i]!='\0')
                                {
                                ch[i]=ch[i]+(2+i);
                                i++;
                                }
}
void decrypt(char *ch)
{
                int i=0;
                while(ch[i]!='\0')
                                {
                                ch[i]=ch[i]-(2+i);
                                i++;
                                }
}

138.PNG

Advertisements