Sun Mar 11, 2012 5:31 am
void main()
{
char c[10]={0},p[10],d[10]={0};
int i,l,k;
clrscr();
printf("Enter msg:");
gets(p);
printf("\n");
printf("Enter keysize:");
scanf("%d",&k);
puts(p);
for(i=0;i<10;i++)
{
if(p[i]>=65 && p[i]<=96)
{
c[i]=((p[i]-65+k)%26)+65;
}
else if(p[i]>=97 && p[i]<=122)
{
c[i]=((p[i]-97+k)%26)+97;
}
}
printf("\n");
puts(c);
for(i=0;i<10;i++)
{
if(c[i]>=65 && c[i]<=96)
{
if((c[i]-65-k)<0)
{
d[i]=c[i]-k+26;
}
else
{
d[i]=((c[i]-65-k)%26)+65;
}
}
else if(c[i]>=97 && c[i]<=122)
{
if((c[i]-97-k)<0)
{
d[i]=c[i]-k+26;
}
else
{
d[i]=((c[i]-97-k)%26)+97;
}
}
}
printf("\n");
puts(d);
getch();
}
Mon Feb 11, 2013 10:04 pm
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.