I am trying to complete a program but the leading zero gets removed when it is a read as an int. I need this leading zero in the event a user enters a zero at the start because I am using it to do math with later in the program and can't just add the leading zero in the printf.
printf("Enter the first 6 digits of the barcode: \n");
scanf("%i", &n1);
printf("Enter the first 6 digits of the barcode: \n");
scanf("%i", &n2);
//Splits number1 into individual digits
count1 = 0;
while (n1 != 0){
array1[count1] = n1 % 10;
n1 /= 10;
count1++;
}
count2 = 0;
while (n2 > 0){
array2[count2] = n2 % 10;
n2 /= 10;
count2++;
//Steps 1-3
int sumo = array1[5]+array1[3]+array1[1]+array2[5]+array2[3]+array2[1]; //adds odd
int sume = array1[4]+array1[2]+array1[0]+array2[4]+array2[2]; //adds even without 12
int sumd = 3*sumo; //multiplies odds
int sum = sume+sumd; //adds above and evens
int chec = sum%10;
int check = 10-chec;
Entire program can be found here