Question:
Encryption DXC Automata Fix Questions AMCAT
char* encryption(char* str)
{
// write your CODE here
}
Solution:
#include<stdio.h>
#include<string.h>
char* encryption(char* str) {
int i,j=0,k,ws=0,val;
char word[20];
int len=strlen(str);
for(i=0;i<=len;i++){
if(str[i]==' ' || str[i]=='\0')
{
val=0;
for(k=j-1;k>=0;k--)
{
word[k]=word[k]+val;
val++;
if(word[k]>122)
word[k]='a'+(word[k]-123);
str[ws+k]=word[k];
}
ws=i+1;
j=0;
}
else
word[j++]=str[i];
}
return str;
}
int main()
{
char str[]="yum feed",*s;
s=encryption(str);
printf("%s",s);
return 0;
}