C Programming Challenge: Write Rot13 Version Of String

Write a function that takes a string and returns the ROT13 version of the string; you may assume that the character set is ascii. What is the meaning of “Cebtenzzvat Cenkvf vf sha!”

Replies

  • silverscorpion
    silverscorpion
    Iterate over each character in the string.
    If the character is an alphabet, add or subtract 13 from its ascii value, depending on the alphabet.
    If it's a non-alphabet, keep it as it is.
  • silverscorpion
    silverscorpion
    And "Cebtenzzvat Cenkvf vf sha" translates to "programming in praxis is fun"

    P.S I can't seem to be able to post python code. When I add the code in the reply and try to post, an error message saying "Internal server error" appears.
    Without the code, it seems to be ok.
  • silverscorpion
    silverscorpion
    The code could be,

    #include
    #include
    int main()
    {
        char s[50],new[50];int len,i,temp;
        printf("Enter The String To Be Encrypted");
        gets(s);
        len=strlen(s);
        for(i=0;i64&&s[i]<91) {
                if(s[i]>77)
                    s[i]=s[i]-13
                else
                    s[i]=s[i]+13
            }
            else if(s>96&&s<123) {
                if(s>109)
                    s[i]=s[i]-13
                else
                    s[i]=s[i]+13
            }
        }
     
        printf("The ROT13 Version Of The String Is\n\n");
        printf("%s",s);
    }
  • Mystique_Myth
    Mystique_Myth
    sorry dude.. actually i was unable to post that code.. can't get that "[]" in the code.. datz y i deleted it
  • Kaustubh Katdare
    Kaustubh Katdare
    Mystique_Myth
    sorry dude.. actually i was unable to post that code.. can't get that "[]" in the code.. datz y i deleted it
    Wrap it in the 'code' tags.
  • silverscorpion
    silverscorpion
    Hmm.. I can post C code, but not Python code?? :O

You are reading an archived discussion.

Related Posts

In a typical HR interview, you might be asked to differentiate between Confidence and Overconfidence. Can you list a few points?
I need your help..i am doing BE(ece),i finished my first year with 9.2 gpa..then entered into our department..in my mind there is only one thing that came into my mind...
This comes as a tricky question for many. How would you answer if the interviewer asks you, "Aren't you over qualified for this job profile?"
All the CS & IT Students have to study 'Turing Machine' under computation theory. Quoting from wikipedia: A Turing machine is a device that manipulates symbols on a strip of...
This question will be asked only to the people who are experienced i.e. it will be not asked to freshers. What is the best answer to the question: "Why should...