#include <stdio.h>
#include <math.h>

main()
{
  int a,b,c,d,e,f,g,h,i,j,x,y,count,check;

  printf("Please type in the 6-digit number to be verified, \n");
  printf("then type in [control-z]: \n");
  count = 1;
  while ((x = getchar()) != EOF)
    { y = x - '0';
      if (count >= 1 && count <= 6)
	switch (count)
	{
	  case 1:
	       a = (y * 2)/10;
	       b = (y * 2)%10;
	       break;
	  case 2:
	       c = y;
	       break;
	  case 3:
	       d = (y * 2)/10;
	       e = (y * 2)%10;
	       break;
	  case 4:
	       f = y;
	       break;
	  case 5:
	       g = (y * 2)/10;
	       h = (y * 2)%10;
	       break;
	  case 6:
	       check = y;
	       break;
	}
	count++;
       }
       if (count != 7)
	 printf("Number must be six digits long to verify properly. \n");
       i = a + b + c + d + e + f + g + h;
       j = i%10;
       if (check == j)
	 printf("Number verified \n");
	 else
	   printf("Not able to verify number \n");
    }
