-->

Facebook

Jasper Roberts - Blog

Wednesday, February 24, 2016

(IS2) Write a Program to implement-MODIFIED CEASER CIPHER

#include<stdio.h>
#include<conio.h>
void main()
{
            int i,no,c;
            char om[30],em[30];
            clrscr();
            printf("Enter Original Text: ");
            gets(om);
            printf("Enter Key No: ");
            scanf("%d",&no);
            c=no/26;
            if(no>26)
                        no=no-(c*26);
            for(i=0;om[i]!=NULL;i++)
            {
                        if(om[i]==' ')
                        {
                                    em[i]=' ';
                        }
                        else if(om[i]>='a' && om[i]<='z')
                        {
                                    em[i]=om[i]+no;
                                    if(em[i]>'z' || em[i]<0)
                                    {
                                                em[i]=em[i]-26;
                                    }
                        }
                        else
                        {
                                    em[i]=om[i]+no;
                                    if(em[i]>'Z')
                                    {
                                                em[i]=em[i]-26;
                                    }
                        }
            }
            em[i]=NULL;
            printf("\n Your Original Text = %s ",om);
            printf("\n Enter Encrypted Text = %s ",em);
            getch();

}


OUTPUT:

is programs

No comments:

Post a Comment