Advertisement
Adrita

encode decode(lab)

May 4th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.46 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. int main()
  4. {
  5.     int n,i;
  6.     scanf("%d",&n);
  7.     char str[100];
  8.     scanf("%s",str);
  9.     for(i=0;i<strlen(str);i++)
  10.     {
  11.         str[i]=str[i]+n;
  12.         if(str[i]>'z')
  13.             str[i]=str[i]-26;
  14.     }
  15.     printf("Encoded word is %s\n",str);
  16.     for(i=0;i<strlen(str);i++)
  17.     {
  18.         str[i]=str[i]-n;
  19.         if(str[i]<'a')
  20.             str[i]=str[i]+26;
  21.     }
  22.     printf("Decoded word is %s",str);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement