#include
int main(void){
int i=0,z;
char s,l[26],search,c,a[26];
for(c = ‘A’; c <= ‘Z’; ++c){a[i]=c; i++;}i=0;
for(s = ‘a’; s <= ‘z’; ++s){l[i]=s; i++;} printf( “\n Enter a character:”); scanf(“%c”, &search); if(search>=65 && search<=90){ // checking the char type

// loop for A-z
for (i = 0; i < 26; i++){
if(search==a[i]){
if (a[i]==a[0] || a[i]==a[1] || a[i]==a[2]){ //conditional check for a,b,c
if(a[i]==a[0]){printf(“XYZ”);}else if( a[i]==a[1]){printf(“YZA”);}else if( a[i]==a[2]){ printf(“ZAB”);} //static value part printf
}else{
for (z=i-3; z<=i-1; z++)printf(“%c”,a[z]);//conditional loop for 1st 3 char
}
if(a[i]==a[23]||a[i]==a[24] || a[i]==a[25]){
if(a[i]==a[23]){ printf(“XYZA”);}else if( a[i]==a[24]){ printf(“YZAB”);}else if( a[i]==a[25]){ printf(“ZABC”);}
}else{
for (z=i; z <= i+3; z++) printf(“%c”,a[z]); }//conditional loop for 1st 3 char
}
}
}else{

// repeated for loop for a-z
for (i = 0; i < 26; i++){
if(search==l[i]){
if (l[i]==l[0] || l[i]==l[1] || l[i]==l[2]){
if(l[i]==l[0]){printf(“xyz”);} else if( l[i]==l[1]){ printf(“yza”);} else if( l[i]==l[2]){ printf(“zab”);}}else
{
for (z=i-3; z<=i-1; z++)
printf(“%c”,l[z]);
}
if(l[i]==l[23]||l[i]==l[24] || l[i]==l[25]){
if(l[i]==l[23]){printf(“xyza”);}else if( l[i]==l[24]){ printf(“yzab”);} else if( l[i]==l[25]){ printf(“zabc”);}}else
{
for (z=i; z <= i+3; z++)
printf(“%c”,l[z]);
}
}
}
}
return 0;
}

Leave a reply