/* file: simpleEncoding.c */ /* author: Benediktus Firstian Pradipta (b.f.pradipta@studnet.rug.nl) (S5241529)*/ /* Description: Inputs a string of text and shifts character by a position relative to their order. Eg first character is shifted once. Only letter characters are shifted, Uppercase characters remains Uppercase. */ #include #include int main(int argc,char*agrv[]) { char input; // x=1 because it starts from the first position int x=1; // inputs characters untill a new line is entered while((input=getchar())!='\n'){ // to sort out the capital letter character from other special characters if (input >= 'A' && input <= 'Z'){ // Shifts the value of the input, after calculating how far away from 'Z' it is, and counts up from 'A' input = (((input + x - 'A')%26) + 'A'); } // same code as the previous one but for lowercase letters else if ((input >= 'a' && input <= 'z')){ input = (((input + x - 'a')%26) + 'a'); } // adds a value to the x(as it goes to the next character) printf("%c", input); // prints the new value input, if character is not a letter it doesnt change x++; } printf("\n"); return 0; }