Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please write in C language: // upc.c program : 6. European countries use a 13-digit code, known as a European Article Number (EAN) instead of

please write in C language:

image text in transcribed

// upc.c program :

image text in transcribed

6. European countries use a 13-digit code, known as a European Article Number (EAN) instead of the 12-digit Universal Product Code (UPC) found in North America. Each EAN ends with a check digit, just as a UPC does. The technique for calculating the check digit is also similar Add the second. fourth. sixth, cighth, tenth. and twelfth digits. Add the first, third. fifth. seventh. ninth. and eleventh digits. Multiply the first sum by 3 and add to the second sum Expressions Subtrac from the total. Compute the remainder when the adjusted total is divided by 10 Subtract the remainder from 9 For example, consider Glloglu Turkish Delight Pistachio & Coconut, which has an EAN of 8691484260008. The first sum is 6+18+2+0+0 17, and the second sum is 89+ 4 +46+0 31. Multiplying the first sum by 3 and adding the second yields 82. Subtac ing I gives 81. The remainder upon dividing by 10 is . When the remainder is subtracted from 9, the result is 8, which matches the last digit of the original code. Your job is to mod ify the upc.c program of Section 4.1 so tha it calculates the check digit for an EAN. The user will enter the first 12 digits of the EAN as a single number: Enter the first 12 digits of an EAN: 86914 8426000 Check diait: 8 upc.c /*Computes a Universal Product Code check digit / #include int main (void) first sum, second sum, total; printf ("Enter the first (single) digit: ") scanf ( " % ld", &d) ; printf ("Enter first group of five digits: " scanf ( " % 1d%ld%ld% ld%ld", &il, &i2, &13, &14 , &i5); printf ("Enter second group of five digits: ") The missing check digits are 8 (Jif) and 6 (0cein Spray). Chapter 4 Expressions first sumd12 i4 + jlj3 j5 secondsum i1 + 13 + 15 + j2 + j4; total 3first sum second_sum; - printf("Check digit: %d ", 9 - ((total - 1) % 10)); return 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Entity Alignment Concepts Recent Advances And Novel Approaches

Authors: Xiang Zhao ,Weixin Zeng ,Jiuyang Tang

1st Edition

9819942527, 978-9819942527

More Books

Students also viewed these Databases questions