Hi everyone and I'm sorry if this has been asked here, but I've spent hours online trying to figure out why only the mixed (upper and lower) tests failed. I don't know what I'm overlooking or missing out.
Here is a sample of my calculation.
for (int i = 0, n = strlen(p); i < n; i++)
{
if isupper(p[i])
{
printf("%c", ((p[i] -'A' + k) % 26) + 'A');
}
if islower(p[i])
{
printf("%c", ((p[i] - 'a' + k) %26) + 'a');
}
else
{
printf("%c", p[i]);
}
}
printf("\n");
return 0;
}
Here are the results of checkcs50: BARFOO with 3 keys:- expected output: EDUIRR actual output: EBDAURIFRORO
BaRFoo with 4 keys:- expected output: FeVJss actual output: FBeVRJFss
I really appreciate any help! Thank you all in advance.