I wrote this code but it didn't work for all numbers. (RSA algorithm)
using namespace std;
int main () {
    int x;
    int p = 13;
    int q = 11;
    long n = p * q;
    long φ = (p - 1) * (q - 1);
    long e = φ - 1;
    long d = φ + e;
    cout<<"Plz enter a number.\n";
    cin>>x;
    long y = pow (x,e);
    long a = y % n;
    long b = pow (a,d);
    long c = b % n;
    cout<<"Original = "<<x<<endl;
    cout<<"Encrypted = "<<a<<endl;
    cout<<"Decrypted = "<<c<<endl;
    return 0;
}
For some numbers, encrypted and decrypted show same number, and for larger numbers they show random numbers.
 
     
    