-3
I’m having trouble with this code.
I have to read from the 9 digits of isbn and generate the scanner code, this is ok.
But I have to do a repeat where the program only closes when the user type 000000000 and I’m not able to find a way, I tried so but it didn’t work:
#include <stdio.h>
char isbn_dv(char isbn[9])
{
while (isbn[9]!=000000000){
int s1 = 0;
int s2 = 0;
for (int i = 0; i < 9; i++)
s1 += isbn[i] - '0', s2 += s1;
int digito = 11 - ((s1+s2) % 11);
if (digito == 11) return '0';
if (digito == 10) return 'X';
return '0' + digito;
}
}
int main(void){
char isbn[9];
scanf("%9s", isbn);
printf("%s-%c", isbn, isbn_dv(isbn));
return 0;
}