Answer to Question #218845 in C for Hemambar

Question #218845

write a C program to convert the string "CEASER " to "HJFXJW "without using inbuilt function


1
Expert's answer
2021-07-24T07:07:33-0400


#include<stdio.h>
 
int main()
{
    char s[100]="CEASER";
    char ch;
    int i, key;
    key=5;
    for(i = 0; s[i] != '\0'; i++){
        ch = s[i];
        if(ch >= 'a' && ch <= 'z'){
            ch = ch + key;
                if(ch > 'z'){
                    ch = ch - 'z' + 'a' - 1;
                }
            s[i] = ch;
        }
        else if(ch >= 'A' && ch <= 'Z'){
            ch = ch + key;
                if(ch > 'Z'){
                    ch = ch - 'Z' + 'A' - 1;
                }
            s[i] = ch;
        }
    }
    printf("%s", s);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS