Вы находитесь на странице: 1из 2

Is practical

090120116042

GANDHINAGAR INSTITUTE OF TECHNOLOGY


IT DEPARTMENT PRACTICAL-1 AIM:Write a C program for ceasar cipher.
#include<stdio.h> #include<conio.h> void main() { char mt[15]; int a[100],i,j,k,n,b[100]; clrscr(); printf("enter the string"); scanf("%s",&mt); printf("enter the key "); scanf("%d",&k); printf(" the cipher text "); j=0; for(i=0;i<mt[i]!='\0';i++) { j++; a[i]=((int)mt[i])+k; if(a[i]>122) { a[i]=a[i]+26; } printf("%c",a[i]); } printf("\n the decipher "); for(i=0;i<=j-1;i++) { b[i]=a[i]-k; if(b[i]<97) { b[i]= b[i]-26; } printf("%c",b[i]); } getch(); }

OUTPUT:Enter the string savan Enter the key 3 The cipher text vdydq The decipher savan

Page 1

Is practical

090120116042

Page 2

Вам также может понравиться