C program to encode a string and display encoded string

C program to encode a string and display encoded string:
If you are using any software then below program will not give an error, but if you are using TURBO C then you have to make some changes like: void main() and some function like clrscr() or getch().

#include<stdio.h>
#include<conio.h>

void Encode(char str[])
 {
   int i=0;
   while(str[i] != '\0')
    {
      str[i]=str[i]-30;  // Subtract 30 From Character to make encode
      i++;
    }
  printf("\nEncoded String : %s",str);
}

main()
{
   char str1[20];

   printf("Enter the String to Encode : ");
   gets(str1);
   Encode(str1);
}

OUTPUT:

Enter the String to Encode : BaronTuts

Encoded String : `ÉìîrôÆæ

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.