C++ Programme for a function to encode a string that is passed to it. The string should get converted into an unrecognizable form.



#include<iostream.h>
#include<conio.h>
#include<string.h>


#include<stdio.h>


void encode(char str1[],int l);


int main()
{
               char str[30];
               cout<<"Enter an string:";
               gets(str);
               int len=strlen(str);
               encode(str,len);
               return 0;
}

void encode(char str1[],int l)
{
               int i;
               for(i=0;i<l;i++){
                              str1[i]=str1[i]+10;
               }
               cout<<"\nThe encoded string is:"<<endl;
               for(i=0;i<l;i++){
                              cout<<str1[i];
               }
               cout<<"\nThe proper string is:"<<endl;
               for(i=0;i<l;i++)
                              str1[i]=str1[i]-10;
               for(i=0;i<l;i++)
                              cout<<str1[i];
}





OUTPUT:

 Enter an string:KARTHIK
                                                                               
The encoded string is:                                                         
UK\^RSU
The proper string is:                                                          
KARTHIK 

No comments:

Post a Comment