vigenere cipher c language
<p>I am trying to make a vigenere cipher in C language. The input is only supposed to be alphabetical characters (a->z). </p>

<p>Currently my issue is the output only puts out 4 characters and outputs strange characters outside the alphabet. I have created the if statements to prevent this, but it seems they are not working. Any advice? </p>

<pre><code>#include &lt;stdio.h&gt;


int main(){
    int i=0;
//Vigenere Cipher-- keyword is "apple"
//a = 1  value shift
//p = 16 value shift
//p = 16 value shift
//l = 17 value shift
//e = 5  value shift
 //cleaning out string array
 char guy[100];

printf("Enter the plain text: ");
fgets(guy, 100, stdin);//takes user's input

while (guy[i] != '\0'){ //while loop that runs until it reaches the end of the string

    if ((i%5==0) || i==0){ //checks to see which character it is in the string, for instance the numbers 0,5,10,15,20 should all be added by 1
    guy[i] = guy[i]+1;
    if (guy[i]&gt;'z' &amp;&amp; guy[i]&lt;'A'){
            guy[i]-25;
    }
    if (guy[i]&gt;'Z' &amp;&amp; guy[i]&gt;'A'){
        guy[i]-25;
    }
    }

    if (((i-1)%5==0) || i==1){ //all numbers that are second in the key word 'apple', such as 1,6,11,16
        guy[i]=guy[i]+16;
        if (guy[i]&gt;'z' &amp;&amp; guy[i]&lt;'A'){
            guy[i]-25;
        }
        if (guy[i]&gt;'Z' &amp;&amp; guy[i]&gt;'A'){
            guy[i]-25;
        }
    }
    if (((i-2)%5==0) || i==2){// all numbers that are third to the key word 'apple' , such as 2,7,12,17,22
        guy[i]=guy[i]+16;
        if (guy[i]&gt;'z'&amp;&amp; guy[i]&lt;'A'){
            guy[i]-25;
        }
        if (guy[i]&gt;'Z'&amp;&amp; guy[i]&gt;'A'){
            guy[i]-25;
        }
    }
    if(((i-3)%5==0) || i==3){// all numbers that are fourth to the key word 'apple', such as 3,8,13,18
        guy[i]=guy[i]+17;
        if (guy[i]&gt;'z'&amp;&amp;guy[i]&lt;'A'){//takes care of z
            guy[i]-25;
    }
        if (guy[i]&gt;'Z' &amp;&amp; guy[i]&gt;'A'){//takes care of Z
            guy[i]-25;
        }
    }
    if(((i-4)%5==0) || i==4){// all numbers that are fifth in the key word 'apple', such as 4,9,14,19
        guy[i]=guy[i]+5;
        if (guy[i]&gt;'z'&amp;&amp; guy[i]&lt;'A'){
            guy[i]-25;
        }
        if (guy[i]&gt;'Z' &amp;&amp; guy[i]&gt;'A'){
            guy[i]-25;
        }
    }
    else {
    i++;
    }
    }
printf("Encrypted text is: %s\n",guy);
}
</code></pre>