I am trying to write an AC program that reads a barcode (which is 10 digits long) from stdin, first Adds 9 digits of barcode, and if the second digit of 9 digits is equal to 10th digit in barcode, then it writes barcodes to carry out the studs.
Even what I have so far, some people help me or tell me what I have got or what to add. Would it be possible to put the entire barcode in a character array and first add 9 digits and compare the value of the bar [9]? How would I do this? Thanks
#include & lt; Stdio.h & gt; Int main (zero) {int sum = 0; Four times [10]; Int i; For (i = 0; i
correction
- < Change to Li> int bar [10] four times [10], because you are just managing interstates
- Array starts with index 0 and
SIZEOFARRAY-1
< Signals like primitives like -
int
,float
can not be used as if you havesum [1] == bar [ 10]
. Here the zodiac is just an integer type, where as bar is an array of integers -
final but 2-digit test and tenth digit of barcode
Int secondDigit = sum% 100; For // 18 9, this gives 8 second diagram = 8 digit for digit digit / 10/8/8 if it is the second return 8 (second digit == bar [9]) // See SIZEOFARRAY which is 10 - 1 = 9 would be the last array element {// as you wanted to display barcode}
No comments:
Post a Comment