Lynes_Tony_Lab5.c - Anthony Lynes Lab5 CSCI 112#include <stdio.h> int sum(int int\/declare sum as 2 arguements second being an array void

# Lynes_Tony_Lab5.c - Anthony Lynes Lab5 CSCI 112#include...

This preview shows page 1 out of 1 page.

/* * Anthony Lynes * Lab5, CSCI 112 * 3/4/16 */ #include <stdio.h> int sum(int, int[]);//declare sum as 2 arguements, second being an array void Barcode(int *);//assigns pointer 'Barcode' to program void Check(int, int); //this function will sum the even digits int sum(int x, int a[]){ int s=0; for( x=x; x<11; x=x+2){ s=s+a[x]; } return s;} void Barcode(int* a){ //stores barcode into array printf("Enter a barcode to check. Seperate digits with a space >\n"); scanf("%d %d %d %d %d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4], &a[5], &a[6], &a[7], &a[8], &a[9], &a[10], &a[11]); } //this function will check to see if the first digit matches the last //if/else statement will work best for this void Check(int x, int y){ if(x==y){ printf("STEP 5: Check digit and last digit match\n"); printf("Barcode is VALID.\n\n");//tells user digits match } else{ printf("STEP 5: Check digit and last digit do not match\n"); printf("Barcode is INVALID.\n\n");//tells user digits do not match

#### You've reached the end of your free preview.

Want to read the whole page?

• Spring '14
• Rafal A. Angryk
• Return statement, Summation, Void type, check digit