Thursday, 3 March 2016

Ceaser Cipher Program in C++

"Nice One Program"

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>

void main()
{ clrscr();
  int choice,l;
  char a[10];
  cout<<"Enter Choice:\nCODING:1\nDECODING:2\nChoice:";
  cin>>choice;

  int i,t;
  if(choice==1)
  { cout<<"Enter Object:";
   cin>>a;
   l=strlen(a);

 for(i=0;i<l;i++)
  a[i]=toupper(a[i]);

   for(i=0;i<l;i++)
   { t=a[i];
     if(t==90)
     { a[i]=67;
      cout<<a[i]<<" ";
     }
     else if(t==89)
     {a[i]=66;
      cout<<a[i]<<" ";
     }
     else if(t==88)
     {a[i]=65;
      cout<<a[i]<<" ";
     }

     else
     { a[i]=t+3;
      cout<<a[i]<<" ";
     }

   }
  }//END Of Coding

  else if(choice==2)
  {cout<<endl<<"Enter The CODED Form:";
   cin>>a;
   l=strlen(a);
   for(i=0;i<l;i++)
   a[i]=toupper(a[i]);

   for(i=0;i<l;i++)
  { t=a[i];

    if(t==65)
    { a[i]=88;
     cout<<a[i]<<" ";
    }
    else if(t==66)
    { a[i]=89;
     cout<<a[i]<<" ";
    }
    else if(t==67)
    { a[i]=90;
     cout<<a[i]<<" ";
    }


     else
    { a[i]=t-3;
    cout<<a[i]<<" ";
    }
   }
  }// END OF DECODER


    getch();


}






PLEASE COMMENT DOWN FOR ANY PROBLEM REGARDING CODE
WE WILL SURELY HELP YOU.. THANK YOU FOR VISITING
KEEP VISITING FOR MORE QUESTIONS AND THEIR CODES.

Please Share This Page...

No comments:

Post a Comment