Guest User

Untitled

a guest
Jun 24th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <stdio.h>
  2. int getuserchoice()
  3. {
  4. int n;
  5. printf("---ISBN Validate---");
  6. printf("n1-ISBN Checking");
  7. printf("n2-Quit");
  8. printf("nSelect: ");
  9. scanf("%d", &n);
  10. return n;
  11. }
  12. int main()
  13. {
  14. long a[10];
  15. long sum=0;
  16. int i=0,n=1;
  17. long x;
  18. if(getuserchoice()==1)
  19. {
  20.  
  21. printf("nEnter the values for ISBN number : ");
  22. scanf("%ld", &x);
  23. if(x>0)
  24. {
  25. while(x>0)
  26. { a[i]=x%10;
  27. x=x/10;
  28. i++;
  29. }
  30. }
  31.  
  32.  
  33. for(i=0;i<10;i++)
  34. printf("%ldt", a[i]);
  35. for(i=0;i<10;i++)
  36. {
  37. sum+=a[i]*n;
  38. n++;
  39. }
  40. if(sum%11==0) printf("nISBN Status: Valid!");
  41. else printf("nISBN Status: Invalid!");
  42. }
  43. else printf("nSee you later!");
  44. getchar();
  45. return 0;
  46.  
  47. }
Add Comment
Please, Sign In to add comment