0

This is my code:

 for(int i = 0, len = strlen(plaintext); i < len; i++)
{
    char c = plaintext[i];
    if (isalpha(c))
    {
        char p = 'A';
        if (islower(c))
        {
            p = 'a';
        }
        printf("%c", (c - p + key) % 26 + p);
    }
    else
    {
        printf("%c",c);
    }
}

printf("\n");

}

And this is the error I get:

Expected Output:
ciphertext: FeVJss
Actual Output:
chipertext: FeVJss

I didn't write the entire code, just the part that matters. But as you can see expected output and actual output are exactly the same, so what is the problem. I thought it could be with the new line not printing but I don't see how that would be the problem since I wrote .\n after the main loop.

1

The error is that instead of printing the word 'ciphertext', it prints 'chipertext'. Please correct that.

Hope this helps. If it does then please check the tickmark

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .