I want to make a Caesar cipher for numbers. (Add 3 to all digits)
Input: 52 Output:85
Input:954 Output:287
Input: -10457 Output:-43780
I'll be very glad if someone helps me with this.
I tried this but when I input the number less than 5 digits it outputs 3 to beginning
When I input 52 it outputs 33385
#include<stdio.h>
#include<stdlib.h>
int main() {
int number,operation;
printf("Enter the number: ");
scanf("%d",&number);
printf("%d", ((number/10000)+3)%10);
printf("%d", (((number % 10000)/1000)+3)%10);
printf("%d", (((number % 1000)/100)+3)%10);
printf("%d", (((number % 100)/10)+3)%10);
printf("%d\n", ((number % 10)+3)%10);
printf("press 1 to continue or 2 for exit.");
scanf("%d",&operation);
switch(operation) {
case 1:
printf("Enter the number: ");
scanf("%d",&number);
printf("%d", ((number/10000)+3)%10);
printf("%d", (((number % 10000)/1000)+3)%10);
printf("%d", (((number % 1000)/100)+3)%10);
printf("%d", (((number % 100)/10)+3)%10);
printf("%d\n", ((number % 10)+3)%10);
break;
case 2:
break;
}
return 0;
}