#include <cs50.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, string argv[])
{
if(argc != 2)
{
printf("Try again. Your key was incorrect.\n");
return 1;
}
int k = atoi(argv[1]);
if(k <= 0)
{
printf("Try again. Your key was not in the accepted range of 0 to 25, or was a string.\n");
return 1;
}
if(k >= 26)
{
printf("Try again. Your key was not in the accepted range of 0 to 25, or was a string.\n");
return 1;
}
string t = GetString();
int i = 0;
for (int n = strlen(t); i < n; i++)
{
if(isalpha(t[i]))
{
if(isupper(t[i]))
{
int l = t[i];
l = l - 65;
l = (t[i] + k)%26;
l = l + 65;
char c = l;
printf("%c", c);
}
if(islower(t[i]))
{
int v = t[i];
v = v - 97;
v = (t[i] + k)%26;
v = v + 97;
char z = v;
printf("%c", z);
}
}
printf("%c", t[i]);
}
printf("\n");
}
The output of this code is UCfhceceqsce with a key of 5 and a input of Cheese. The desired output is Hmjjxj. This is for caesar.c. Thanks in advance.