String Problem: ASCII table related

Problem: Write a program which takes a string of alphabet as input and replace all the characters with the 3rd immediate character of it. All the alphabets of the input string will be small letter. [If user gives input “abc” you should print “def”, if user gives input “xyz” you should print “abc”]

mycode:

#include<stdio.h>
int main(){
int i,j;
char str[20];
gets(str);
for(i=0;str[i]!='\0';i++);

for(j=0;j<i;j++)
{
if(str[j]>='x' && str[j]<='z')
{
    str[j]=str[j]-23;
}
else{
    str[j]=str[j]+3;
}
putchar(str[j]);
}
return 0;
}

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

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