1 like 1 dislike
1.7k views

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 (12.1k points)
ID: 32706 - Available when: 2017-11-15 14:10 - Due to: Unlimited
| 1.7k views

49 Answers

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

int ISBN[13];
int sum;
int checkdigit;
int main()
{
** ** * * *** * *** ******* *** ** ** *** **** *** * * * ** ** * * * ** ** * **** * * *** * * * * * * * * * * *** * ** * * * * * * ** ** * ** * * * ******** ***** ***


*** * * ** * ** *** = *** *** * * *** * * * * ** * * *** ** ***** *

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

* * * ** * * ** ** ** 0;
}
answered by (-286 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 <stdio.h>
int main()
{
* **** * ** * * * *** ** a,b,c,d,e;
* * * * ** ** * * ** f,g,h,i,j;
** ***** ****** * * ** k,l,m,z;
***** ** * ***** * * * * * *** *** ** * **** * ** *** *** ** * ** *** ** * * *** * * * * *** *** *** *** **** * ****** * ** ***
* ** * ** * ******* ** * ** ** * * **
* ******** ** *** * * (z==m)
* * * * * ** * ** ****
******* ** ****** *** ** * **** ** * ***** ** * *** * ISBN");
    }
** *** ** **** ** ** *
* **** * * * * *** *
* * * * * ** * * *** * * * * ** **** **** ** * ISBN");
    }
* * * ** * * ** 0;
}
answered by (-229 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 <stdio.h>
//isbn number
int main(void)
{
** ** ***** * ** * ** * *** * ** * *** **
* ****** * *** ****** ** * *** * * ** * * * * * * ** * * *** ** ** ** ** * * ** * **** **** * ** * * ** * * * * * ********** * * *
* *** ** * * * * ** * ******* ***** *
**** ** * *** * *** ***** *
* * * * * * *** **** * *** *** **
** * ** ** * * **** * *********** * * *** * * ******* ** ** ISBN");

** ** * ** * ** ** ** * printf("Invalid ISBN");
**** **** * * ****** * 0;
}
answered by (-304 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<stdio.h>
int main(void)
{
* * * * *** *** ** * *** ** * ** * ** * **
***** * **** *** ***** ** * * * * *** **** *** ** **** * * * * * * * * ***** * * * **** * *** * * **** *** * * * *** ** *** * *

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

** ** ** *** ** *** ** * *** *** *
* ** **** * ** ** * *
****** * * ******* ** *** ***** *** *** **** ***** * * * * ISBN");
    }
* * *** * * * **
    {
* * ** * * * * *** * * * ***** * ** * ** ** ISBN");
**** ** ** * *** *
  return 0;

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

int main()
{
*** **** * * *** * * ** * ** ** * * * **
* **** * * * ** *** **** *** ** ***** *** *** * * *** *
** * * * * *** * * *** * * * * * ** * *** * ** ** *
* * ** * ******* ** ** **
*** * **** * *** (m==o)
* * *** **** *** **** ** ISBN\n");
* ** * * **** *** * ** *******

* * ** * * * * * ** ** * 0;
}
answered by (-284 points)
0 0
prog.c: In function 'main':
prog.c:7:13: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int' [-Wformat=]
     scanf("%d",a,b,c,d,e,f,g,h,i,j,k,l,m);
             ^
prog.c:7:11: warning: too many arguments for format [-Wformat-extra-args]
     scanf("%d",a,b,c,d,e,f,g,h,i,j,k,l,m);
           ^~~~
0 like 0 dislike
Hidden content!
#include * * * ****
#include * ** ***

int main()
{
* * * * * * * ** ** * a, b, c, d, e, f, g, h, i, j, k, l, m;

** * ****** * ** * * * ***** total = 0;

*** ** ** ** ***** * ** check = 0;

* * ** ** ** * ** ** ** ** ** **** *** *** * ** * ** * * ** * ** ** *** * *** * * * * *** * *** * &j, * * * * ** * ******

* * ** *** * * * **** ***** = a*1 + b*3 + c*1 + d*3 + e*1 + f*3 + g*1 + h*3 + i*1 + j*3 + k*1 + l*3;

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

* * * * ***** * * ** * = m)
* * * ** ** ** * *** *
* * **** * * * *** *** * ** **** *** * ** * ** * * * * ** *
** * * *** * ** * * ** ****
* * ** ** * ** * * ***
* * * * ** * * ** * ** *
** ** * * * ******* ** * * * ** ** * **** ** ** * ** * ** * ** *
* * * * ** ** ******
}
35/100 answered by (-285 points)
0 0
prog.c: In function 'main':
prog.c:12:11: warning: zero width in gnu_scanf format [-Wformat=]
     scanf("%0d%0d%0d%0d%0d%0d%0d%0d%0d%0d%0d%0d%0d", &a, &b, &c, &d, &e, &f, &g, &h, &i, &j, &k, &l, &m);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prog.c:12:11: warning: zero width in gnu_scanf format [-Wformat=]
prog.c:12:11: warning: zero width in gnu_scanf format [-Wformat=]
prog.c:12:11: warning: zero width in gnu_scanf format [-Wformat=]
prog.c:12:11: warning: zero width in gnu_scanf format [-Wformat=]
prog.c:12:11: warning: zero width in gnu_scanf format [-Wformat=]
prog.c:12:11: warning: zero width in gnu_scanf format [-Wformat=]
prog.c:12:11: warning: zero width in gnu_scanf format [-Wformat=]
prog.c:12:11: warning: zero width in gnu_scanf format [-Wformat=]
prog.c:12:11: warning: zero width in gnu_scanf format [-Wformat=]
prog.c:12:11: warning: zero width in gnu_scanf format [-Wformat=]
prog.c:12:11: warning: zero width in gnu_scanf format [-Wformat=]
prog.c:12:11: warning: zero width in gnu_scanf format [-Wformat=]
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main()
{
** * *** * * * * * ** * ** ** * * * * **** * ** *
** * * *** * * * ******
* * ** * ** ***** ** ** *** * * **** * * * *** *** * ** ** * * * ** * *** *** * ***** ** ** * * ** * ** ** * ****** ** * ** * * * **** * * * **
* * ** ** ** * * ** * * * 1*(n1+n3+n5+n7+n9+n11);
* * ** * ******* *** ** 3*(n2+n4+n6+n8+n10+n12);
** * * *** ** * ** **** ** * of first 12 numbers
***** * * * ** ** sum1+sum2;
* ** ** **** ** *** ** *** ** 10 - (sum3%10);
* * **** * * ** ** *** check digit
** * * ** * * * * * * **
* * *** * *** *****
* ******** ** **** * *** *** * ****** * **** * * ** * ISBN");
* * ** * ** * * * *
**** * *** *** *** * * * * * * *
    {
*** * * * ** *** ** ** ** *** ** * **** ****** * ** * * ** ISBN");
* ** * * * * **** ***

* * *** ** *** ** * ** * 0;
}
answered by (-323 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 <stdio.h>
#include <stdlib.h>

int main()
{
** * ***** ** * * * * *** ** a,b,c,d,e,f,g,h,i,j,k,l,m,sum=0,check;
* ***** * * * ** * * * *** * * ** ****** * ** ** ** ** * ** ** * **** * ** ** * * *** ** *** * * * * ** *** * *

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

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

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

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

* * * * *** ** * 0;
}
answered by (-127 points)
0 0
prog.c: In function 'main':
prog.c:7:51: warning: spurious trailing '%' in format [-Wformat=]
     scanf("%1d%1d%1d%1d%1d%1d%1d%1d%1d%1d%1d%1d%1d%",&a,&b,&c,&d,&e,&f,&g,&h,&i,&j,&k,&l,&m);
                                                   ^
0 like 0 dislike
Hidden content!
#include<stdio.h>
int main()
{
* * * * ** *** * a,b,c,d,e,f,g,h,i,j,k,l,m,sum,che;
** ** * * * * ** * **** *** ** * * * ** * * **** ** * *** * * ** ** * * * * * ** * * * ** * * ** *** * * ** * ** ** * *** * * ** **
* ** *** *** * *** * * * *** ******** ** **** * *
* * * ** * * ** ******* * ** * **
******* * * ** ***** ** ** (che==m)
** * **** **** * * *
** * *** * ** * * * ** * * ** **** ** ** *** *** * ** ISBN");
    }
* ** * * ** ** **
* * **** *** ** * **
** ** * *** * * * * * ** * ** *** * * *** ** * ****** * * ISBN");
** * *** ***** * ***** *
}
answered by (-214 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<stdio.h>
int main()
{
* * * * * * ***** * * a,b,c,d,e,f,g,h,i,j,k,l,m,n;
* * ****** ** ** * ** ** * **** * *** * * * *** * * ** ** ******** * ** **** * * * *** * ** ** *** * * ** * *** ** * * ** ***** ** ** ***
* ** * * * *** * * * * ******* *********
** * * * **
    {
*** ** *** * * *** * * *** * ** * ** ** *** ** * * ** * * ISBN");
** ***** * **** **** *
** * * **** **** * * **
**** * **** *** *** *
***** * *** * * **** *** *** * * ***** ** * ISBN");
* * ***** ** * **

}
answered by (-255 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.100.126
©2016-2024

Related questions

0 like 0 dislike
26 answers
[Exam] asked Dec 9, 2017 in Midterm by thopd (12.1k points)
ID: 36751 - Available when: 2017-11-15 14:10 - Due to: Unlimited
| 1.1k views
2 like 0 dislike
77 answers
[Exercise] Coding (C) - asked Oct 19, 2017 in Chapter 5: Selection Statements by thopd (12.1k points)
ID: 27667 - Available when: Unlimited - Due to: Unlimited
| 2.8k views
12,783 questions
183,443 answers
172,219 comments
4,824 users