0 like 0 dislike

The 13-digit International Standard Book Number (ISBN) is a unique code that identifies a book commercially. The last digit is a check digit used for error detection. To calculate its value, each digit of the first twelve digits is alternately multiplied, from left to right, by 1 or 3. The products are summed up and divided by 10. The check digit is the remainder of the division subtracted from 10. If it is 10, it becomes 0. 

ISBN檢查號的計算方法: 前12個數字,奇數項 乘以 1 , 偶數項乘以 3

For example, assume that the first twelve digits are 978960931961.  

假設號碼前12位是978960931961

(a) (9*1 + 7*3 + 8*1 + 9*3 + 6*1 + 0*3 + 9*1 + 3*3 + 1*1 + 9*3 + 6*1 + 1*3) = 126 

(b) The check digit = 10 – (126 % 10) = 10 – 6 = 4  

檢查號 = 10 - 餘數 = 10 – (126 % 10) = 10 – 6 = 4  

So the valid ISBN is: 9789609319614

Write a program that reads a 13-digit ISBN and checks the last digit to see if it is valid or not. 

寫一個輸入13位ISBN號碼 判斷最後一個數字是否檢查碼即可

#Try 1:

Input:

9789609319614

Output: 

Valid ISBN

 

#Try 2:

Input:

9781482214505

Output: 

Valid ISBN

 

#Try 3:

Input:

9780132936493

Output: 

Invalid ISBN

 

[Exam] asked in Midterm by (11.3k points)
Available when: 2017-11-15 14:10 - Due to: Unlimited
| 253 views

26 Answers

0 like 0 dislike
Hidden content!
#include<stdio.h>

int main(){
    char isbn[12];
    int a,b,c,d,e,f,g,i=0,j;
* * * * **** * * ** ** *** * *** * * * *
* * *** * *** ** **** **
* * *** * * ** *** **** ** *** *
* * ***** ** *** * * * * **
******** ** ******* **** *** * ** *** ** * * **** ** * *
* * * * * *** ** * *
** **** *** ***** * ***
** *** *** *** *** ** * *
* * * * ** ****** *** **
** ** * * * * * **
* * * *** * ******** * * ** * ****** * * ** ** ***** ISBN");
** * * * ** **** * ****
***** *** ** * * * ** *** *** ****** * *** ** *** ISBN");

}
answered by (-32 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include<stdio.h>

int main(){
    char isbn[12];
    int a,b,c,d,e,f,g,i=0,j;
** ***** * * **** *** ***** * * ****** * * * * * * *
*** ***** ** *** ** ** **** ** * * *
* ** * ** * * ** ** *** * * * * * * ** *
* * * ** * * *** * * * **
* * * * * * * * ** * *** *** **** **** * **** ** **
* *** *** * **** ***** * *
** * ** ** * * ***
* * *** * * ** *** **
* * *** * * * ** * ** **
***** * ** *** * *** * * ***
** ***** * ** * ** * ** **** ***** * * ******* * * ISBN");
* * ** ** * * * * * * * ***
** * ******* *** * ** * * **** *** * ** * * * * * ISBN");

}
answered by (-32 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include <stdio.h>
#include <string.h>

int main(){
    ///long long int n = 978960931962;

    long long int n;// = 9789609319614;
    int lastDigit;
    int temp1;
    int sum=0;
    int check=0;

* ** ****** * * **** * * *** ** * * *

** *** * ** * * *** ** * **** ** * * ** * = n%10;
* ******* ** * *** * *** ** ** * * ***** * * = n/10;

* ** **** ** * * ** **** *** **** * * = n%10;
* * * *** ** ***** * * * ** **** ** ** = temp1*3;
* * * * *** * **** * * ** ** ** ** * = sum + temp1;
** * * * *** * ** * * * *** *** * *** ***** ** * ** ** * ", temp1);
** * * * * **** * * *** * * = n/10;


*** * * * *** **** ** *** * ** * *** * * ** *** * = n%10;
** ****** **** ** ** * * * ** * * ** * *** * = temp1*1;
* * * *** ** *** ***** * ** ** ** *** = sum + temp1;
* ** * ** **** ***** ** * ** * ******* *** *** ** *** * ", temp1);
* ** * * ** ***** ** * * ***** * **** *** = n/10;

* * * ** *** * ******** ** * *** = n%10;
* * * * ** * ******* * * ** * * * **** * ** = temp1*3;
* **** * ***** * ** *** ** *** * ** *** * *** = sum + temp1;
* ** ** * * * ** * * * *** *** * * * *** * * ", temp1);
** ** ** * ** **** * ** * * * ** * * * = n/10;

**** * ******* * ** ** ** * * ** ** *** ** * * = n%10;
** *** ** *** * * ** **** * * * * * * **** * = temp1*1;
****** ** ** ** * * ** * *** ** ** ****** = sum + temp1;
* ** * ** ** *** *** * * * * * ** ***** ***** * *** * ** *** ** ", temp1);
** * * *** ******* * ****** * * *** * *** = n/10;

** * * * * ***** ** * **** * * ** * * * = n%10;
*** * * **** * ** **** * ** * * ** ** *** = temp1*3;
** ** ***** * *** * * ** * * *** = sum + temp1;
**** * ** *** *** ** * * **** ** * * *** *** * ** * * * ", temp1);
* *** *** *** *** ** **** ** *** * * * * * = n/10;

** ** *** *** ** * *** *** *** * ** **** * * *** ** = n%10;
* ** **** ****** * * **** ** = temp1*1;
* *** ****** * **** ** ** * ** ****** *** = sum + temp1;
* ** ** * ** ****** **** * ** ** * * *** ** * *** ", temp1);
* * * * * ** * * ** * ** * *** *** * = n/10;

********** * ***** ** * ** ** * * ** * * * * ****** = n%10;
** * * * * **** * ** * * * * * *** *** ** ** = temp1*3;
* **** * * ** * * * *** * * * = sum + temp1;
* * * * ** *** **** *** * ** *** ***** * * * * * *** ** ", temp1);
* *** * * * ** * ** * * * **** * ** * = n/10;

** * ** * * ** ****** ** ** ** * ** ** = n%10;
*** *** * * *** * * ** * *** * *** * * * * = temp1*1;
*** *** * * *** * * * * *** * * **** *** = sum + temp1;
** * *** ***** ** ** *** * * * * **** **** * * * ", temp1);
* * ******* **** * * * * * * * *** = n/10;

* * * * **** * * * * ** ** * *** = n%10;
**** *** ** * ********* * *** ** *** * * ****** = temp1*3;
****** * ***** * ** ** ** ** * * *** * *** *** *** = sum + temp1;
** ****** * * * ** * * * * ** * ** *** *** * * *** ", temp1);
* **** *** * * * ** * * ** * ********* = n/10;

** * * * *** * **** *** * * *** * *** *** *** = n%10;
***** * *** ** ** ** *** * ** * * * * * = temp1*1;
*** *** *** ** ** **** ** * ** ** * **** * ** * * = sum + temp1;
* * * *** *** * * ** *** ** ** * * * * * ** * *** ", temp1);
* *** * * * * ** ***** * ** *** * * ** ** * ** = n/10;

* * * * ** *** *** ** ** * ** ** *** **** ** = n%10;
*** * *** ****** * * ** * ** ** ** **** = temp1*3;
* ** *** ** * * ** ** ** * * *** ** * = sum + temp1;
** **** * ** ** * *** **** * * ** * * ** * * * ** * ", temp1);
* * * * ** * ** *** ***** * * ****** * = n/10;

** ***** * * ** * ** * * *** ** * = n%10;
** * * ** * ** **** * ** *** * ** ******** = temp1*1;
* * *** * ********** * *** * ** ** * * * = sum + temp1;
** * * * ** * ** * ** * ** ***** * * ** * * * * * * ** ", temp1);

* * ** * *** ** ** **** * * * **** * * * ** ** * * ** ** * * ",sum);
** * ** * ** * * * ** * *** ** * ** * * ** = 10 - (sum%10);


** ** * ** *** ** * ** *** *** ** *** * **** == check)
*** * * * *** ** ** **** ** ** * * *** * ** ** ** ** * ** * * * ***** ** ISBN\n");
*** * *** *** ** * ** * * *** * * ** **
* ** ******* * *** * * * * ** * ***** ** ** **** * ** ** * * ** *** * * *** ISBN\n");

    return 0;
}
90/100 answered by (-74 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
0 like 0 dislike
Hidden content!
#include * **** * ***


int main (void)
{

int ** * ** ** ** ** **** ** * * * ******* ** ** * *

** * * **** * * * *** * ** * * * ** * *** ** * ** * ** *** * * * * ** ** **** * * * ** * * * ***** * * **** **** * * * * * *



total= * * * ** *** ******* * * ** * * ***** * * * **** *

check_digit= (10-(total%10));

 if (check_digit!=num13)
***** **** ** **** *

* ** * ** * *** * ** ** *** ISBN");

***** * * * ***

** * ** ** ** ** * ** *** * if * * *
* * ** * ** * * ** *** * ** * * *** ****


** * * ***** * ** ** ***** * ** ** ***** * **** * ISBN");

}

return 0;
}
answered by (-107 points)
0 0
prog.c: In function 'main':
prog.c:9:7: warning: too many arguments for format [-Wformat-extra-args]
 scanf("%13d",&num1,&num2,&num3,&num4,&num5,&num6,&num7,&num8,&num9,&num10,&num11,&num12,&num13);
       ^~~~~~
0 like 0 dislike
Hidden content!
#include * * ** ***


int main (void)
{

int ****** ** * *** * * * ***** ************* *

**** * * ** * * * ****** * *** ** * ** *** * * * * * ***** * ** * ******* ***** * **** *** **



total= *** * * * * * ** * *** * * * * *** * * ** *** * * * *

check_digit= (10-(total%10));

 if **** * **
*** ** * * * * *** *

*** * *** * * *** * ** * ISBN");

}

* ** *** * ** * * ** if * ****
** ** * * **** * * * * ** *** ** ***


* * ** * * * * ** * *** ***** **** *** * * *** * *** ISBN");

}

return 0;
}
answered by (-107 points)
0 0
prog.c: In function 'main':
prog.c:9:7: warning: too many arguments for format [-Wformat-extra-args]
 scanf("%13d",&num1,&num2,&num3,&num4,&num5,&num6,&num7,&num8,&num9,&num10,&num11,&num12,&num13);
       ^~~~~~
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main()
{
*** * * * ** * * * ***** * a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, sum1,sum2, sum3, check;
***** ** * * * ** * **** * ** ** * * * * * * * ** **** *** **** *** * **** * ** ***** * ***** ** * ** ** ***** * ** * * ******* * * *

**** * * * * ** ** * *** * ****
* * ** ** ** * * * * *** **** **

* * * *** *** ** ** ** sum1+sum2;

*** * **** * ** ** ** * 10 - (sum3%10);

* * *** ****** * ** *
**** * ** ** *** * * *
** * ** ** ***** * * * * * * * **** ** * ISBN");
** ** * * *** ** * *
**** * *** * ** * *******
*** * * * * * **** ****** **
**** ***** ***** *** *** ** * ***** * ** * **** **** ** ** ** IBSN");
** * * *** ** * *** * ***
* * * ** * * * *** ** *** * * 0;
}
answered by (-233 points)
0 0
prog.c: In function 'main':
prog.c:5:14: warning: format '%ld' expects argument of type 'long int *', but argument 2 has type 'int *' [-Wformat=]
     scanf("%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld", &a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13);
              ^
prog.c:5:17: warning: format '%ld' expects argument of type 'long int *', but argument 3 has type 'int *' [-Wformat=]
     scanf("%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld", &a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13);
                 ^
prog.c:5:20: warning: format '%ld' expects argument of type 'long int *', but argument 4 has type 'int *' [-Wformat=]
     scanf("%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld", &a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13);
                    ^
prog.c:5:23: warning: format '%ld' expects argument of type 'long int *', but argument 5 has type 'int *' [-Wformat=]
     scanf("%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld", &a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13);
                       ^
prog.c:5:26: warning: format '%ld' expects argument of type 'long int *', but argument 6 has type 'int *' [-Wformat=]
     scanf("%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld", &a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13);
                          ^
prog.c:5:29: warning: format '%ld' expects argument of type 'long int *', but argument 7 has type 'int *' [-Wformat=]
     scanf("%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld", &a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13);
                             ^
prog.c:5:32: warning: format '%ld' expects argument of type 'long int *', but argument 8 has type 'int *' [-Wformat=]
     scanf("%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld", &a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13);
                                ^
prog.c:5:35: warning: format '%ld' expects argument of type 'long int *', but argument 9 has type 'int *' [-Wformat=]
     scanf("%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld", &a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13);
                                   ^
prog.c:5:38: warning: format '%ld' expects argument of type 'long int *', but argument 10 has type 'int *' [-Wformat=]
     scanf("%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld", &a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13);
                                      ^
prog.c:5:41: warning: format '%ld' expects argument of type 'long int *', but argument 11 has type 'int *' [-Wformat=]
     scanf("%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld", &a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13);
                                         ^
prog.c:5:44: warning: format '%ld' expects argument of type 'long int *', but argument 12 has type 'int *' [-Wformat=]
     scanf("%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld", &a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13);
                                            ^
prog.c:5:47: warning: format '%ld' expects argument of type 'long int *', but argument 13 has type 'int *' [-Wformat=]
     scanf("%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld", &a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13);
                                               ^
prog.c:5:50: warning: format '%ld' expects argument of type 'long int *', but argument 14 has type 'int *' [-Wformat=]
     scanf("%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld%ld", &a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10,&a11,&a12,&a13);
                                                  ^
0 like 0 dislike
Hidden content!
#include ** *** ****


int main (void)
{

int * ** * ***** ** ** * * ** ** *** ** *** ** * *** **

** * * * * ** * **** **** * ** *** * * * *** ** * *** * * ** ** * ****** * ** *** *** * * ** * * * *** *



total= **** ** * * *** * *** ** ** * * * ** * *
check_digit= 10-(total%10);

 if *** ****** *
*** ** ** * ***** *

**** ** * * ** ** * * * *
}

 else if ** ** * ** *
* *** **** ** * * *

** **** * ***** *** *** **** ***** ****** ** * ** ** * * ** * * * * *

 }

return 0;
}
answered by (-107 points)
0 0
prog.c: In function 'main':
prog.c:9:7: warning: too many arguments for format [-Wformat-extra-args]
 scanf("%13d",&num1,&num2,&num3,&num4,&num5,&num6,&num7,&num8,&num9,&num10,&num11,&num12,&num13);
       ^~~~~~
0 like 0 dislike
Hidden content!
#include * * * **


int main (void){

int ** ** * * ** **** ** ** *** * * ***

** ** **** *** ** * *** ******** *** * * * ****** ** ** *



total= *** ** * ***** * * ** * **** ** ****** * * ** ** * ** *** * * * **
check_digit= 10-(total%10);

 if * ** * **** *
****** ** * * * *


*** *** ** ** * *** ** * *** * ** **
}
 
** if * * ** * * *
* * * *** ** *** * **

** * * * * * * **** * * * * ** * * * * * ******** * ** **

 }

return 0;
}
answered by (-107 points)
0 0
prog.c: In function 'main':
prog.c:8:11: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
 scanf("%13d",num1,num2,num3,num4,num5,num6,num7,num8,num9,num10,num11,num12,num13);
           ^
prog.c:8:7: warning: too many arguments for format [-Wformat-extra-args]
 scanf("%13d",num1,num2,num3,num4,num5,num6,num7,num8,num9,num10,num11,num12,num13);
       ^~~~~~
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main(void)
{
******** * **** * * *** a,b,c,d,e,f,g,h,i,j,k,l,m;
* * *** ******* * ***** * ** ** ** * * *** * ** ** * * ** * * ***** * * *** * *** ** ** ** * ** * ** ** ** **** * * ** *** * *** * *

* ** * * * * * ** ** * check,sum;
* ** *** ** * *** * ** ** * **** ** * ** **
* ** ** ** * * ** * ** **** ** * **** ** * * ***
** * ***** ** * ** *** ** * * * **

* **** * * *** ** **** ****** *
* ****** ** * ** * * * ***
* * * ** * ** ** * ** * ** ** * ******* * *** *
*** * * *** * *

    



* ** ***** **** ** ** * * ** * != m)
* ** * * ** ** * **
** ** ** * ****** * * * *** * ** ***** * * ******* * ** * *** ISBN");
*** ** ** *** * **
*** ** * * ** * *** * *
**** ** ** ** *** ** * *
* * ** * * **** * * * * ***** ** * * ISBN");
    }

return 0;
}
answered by (-249 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
0 like 0 dislike
Hidden content!
#include ** **** * ***
int main (){
int ****** ** ******
int * ****
* * * *** *** number 13: ");
* ** * * * ** * * ** * ** * ** ** ** * **
** * ** ** * ** * * * **
* ** * **** * ****
*** * *
* * * * *
* *
** *** * ** * **
}else {
* * * * ** ** * *** *
}

return 0;
}
answered by (16 points)
0 0
prog.c: In function 'main':
prog.c:6:9: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
 scanf("%d%d%d%d%d%d%d%d%d%d%d%d",i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12);
         ^
prog.c:6:11: warning: format '%d' expects argument of type 'int *', but argument 3 has type 'int' [-Wformat=]
 scanf("%d%d%d%d%d%d%d%d%d%d%d%d",i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12);
           ^
prog.c:6:13: warning: format '%d' expects argument of type 'int *', but argument 4 has type 'int' [-Wformat=]
 scanf("%d%d%d%d%d%d%d%d%d%d%d%d",i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12);
             ^
prog.c:6:15: warning: format '%d' expects argument of type 'int *', but argument 5 has type 'int' [-Wformat=]
 scanf("%d%d%d%d%d%d%d%d%d%d%d%d",i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12);
               ^
prog.c:6:17: warning: format '%d' expects argument of type 'int *', but argument 6 has type 'int' [-Wformat=]
 scanf("%d%d%d%d%d%d%d%d%d%d%d%d",i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12);
                 ^
prog.c:6:19: warning: format '%d' expects argument of type 'int *', but argument 7 has type 'int' [-Wformat=]
 scanf("%d%d%d%d%d%d%d%d%d%d%d%d",i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12);
                   ^
prog.c:6:21: warning: format '%d' expects argument of type 'int *', but argument 8 has type 'int' [-Wformat=]
 scanf("%d%d%d%d%d%d%d%d%d%d%d%d",i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12);
                     ^
prog.c:6:23: warning: format '%d' expects argument of type 'int *', but argument 9 has type 'int' [-Wformat=]
 scanf("%d%d%d%d%d%d%d%d%d%d%d%d",i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12);
                       ^
prog.c:6:25: warning: format '%d' expects argument of type 'int *', but argument 10 has type 'int' [-Wformat=]
 scanf("%d%d%d%d%d%d%d%d%d%d%d%d",i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12);
                         ^
prog.c:6:27: warning: format '%d' expects argument of type 'int *', but argument 11 has type 'int' [-Wformat=]
 scanf("%d%d%d%d%d%d%d%d%d%d%d%d",i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12);
                           ^
prog.c:6:29: warning: format '%d' expects argument of type 'int *', but argument 12 has type 'int' [-Wformat=]
 scanf("%d%d%d%d%d%d%d%d%d%d%d%d",i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12);
                             ^
prog.c:6:31: warning: format '%d' expects argument of type 'int *', but argument 13 has type 'int' [-Wformat=]
 scanf("%d%d%d%d%d%d%d%d%d%d%d%d",i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12);
                               ^
Get it on Google Play Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:162.158.79.171
©2016-2020

Related questions

1 like 1 dislike
49 answers
[Exam] asked Nov 15, 2017 in Midterm by thopd (11.3k points)
Available when: 2017-11-15 14:10 - Due to: Unlimited
| 283 views
2 like 0 dislike
77 answers
[Exercise] Coding (C) - asked Oct 19, 2017 in Chapter 5: Selection Statements by thopd (11.3k points)
Available when: Unlimited - Due to: Unlimited
| 750 views
0 like 0 dislike
15 answers
[Exam] asked Dec 9, 2017 in Midterm by thopd (11.3k points)
Available when: 2017-11-15 14:10 - Due to: Unlimited
| 205 views
10,497 questions
114,159 answers
101,835 comments
3,700 users