ok i am trying to write a program that does a Caesar shift. i am doing the numbers first for example if i have 1456 and i shift every number by 3 i'll get 4789.
so what i got so far is this. So the code below only works for one digit but i dont know how to make it do a whole like like above. any help would be appreciated. I know i have to use a loop but i am not sure how to do that.
Code:
#include <stdio.h>
int main()
{
int temp,k,en,b;
char n;
printf("Input: "); //ask for input
scanf("%c", &n);
printf("shift>"); // by how much should it be shifted
scanf("%d",&k); // assigns it to k
temp= (int)n + k; // converts to integer
if( '0'<=temp && temp <= '9')
en = temp;
else if( temp > '9')
en = temp - 10;
}
printf("%c", en); //prints the converted value of en from integer to char
;