Advertisement
Guest User

chalena yar

a guest
Feb 27th, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3.  
  4. void encrypt(char text[4])
  5. {
  6. int final;
  7.     for(int i=0;i<4;i++)
  8.     {   final = text[i]+10;
  9.         printf("%c",final);
  10.     }
  11. }
  12.  
  13. void decrypt(char text[4])
  14. {
  15. int final;
  16.     for(int i=0;i<4;i++)
  17.     {   final = text[i]-10;
  18.         printf("%c",final);
  19.     }
  20. }
  21.  
  22. void main()
  23. {
  24. char text[4];
  25. int cho;
  26. printf("Enter 1 or 2:");
  27. scanf("%d",&cho);
  28. switch(cho)
  29. {
  30.     case 1:
  31.     printf("Enter text of length 4 to encrypt:");
  32.     gets(text);
  33.     encrypt(text);
  34.     break;
  35.  
  36.     case 2:
  37.     printf("Enter text of length 4 to decrypt:");
  38.     gets(text);
  39.     decrypt(text);
  40.     break;
  41. }
  42.  
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement