0

So i watched zamaylas walkthrough and noticed the formula she showed with is quite clever but i have absolutely no idea how to tell the program that A = 0 and Z = 25 as well as a = 0 and z = 25... do i use a for loop before the main one ... or what? i have no idea what to do please help... U won't need my code for this but here it is anyway

printf("Please enter the plaintext\n");
string p = GetString();

for(int i = 0, n = strlen(p); i < n; i++){
    if(isalpha(p[i])){
        if(isupper(p[i])){
            int u = p[i] + k;
            printf("%c", u);
        }
    }
    else if(isspace(p[i])){
        printf(" ");
    }
}
0

You have to use the asciimath to get the alphabetical index. Just do calculation to get alphabetical index of A that is 0, when you have asciivalue of A that is 65.

| improve this answer | |
  • I get that the formula would be character - 65.. but how do i tell my program that – Nilabha Chatterjee Jun 15 '16 at 18:43

You must log in to answer this question.

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