hm6p1.c - \/geliyang\/input:unique identifier of 15 digits called IMEI\/output:Calculate and display the check digit and Compare it to the Luhn

hm6p1.c - /geliyang/input:unique identifier of 15 digits...

This preview shows page 1 out of 1 page.

//geliyang //3/7/2016 //input:unique identifier of 15 digits, called IMEI //output:Calculate and display the check digit, and Compare it to the Luhn digit. #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> int main(void) { int i = 0; int imei[15]; int sum = 0; printf("Enter 15-digit barcode (separate each digit by space)\n");//ask for input for (i = 0; i < 15; ++i) { scanf("%d", &(imei[i])); } for (i = 0; i < 13; i = i + 2) {//sum all even index sum = sum + imei[i]; } for (i = 1; i <= 13; i = i + 2) {//seperate if (2 * imei[i]>9) { sum = sum + (2 * imei[i]) / 10 + (2 * imei[i] - 10 * (2 *
Image of page 1

You've reached the end of your free preview.

Want to read the whole page?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes