Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main()
  5. {
  6.   char buf[ 7 ];
  7.   int id = 0;
  8.  
  9.   printf( "Modulo-10-Verfahren\n" );
  10.  
  11.   while ( 1 )
  12.   {
  13.     do
  14.     {
  15.       printf( "Kundennummer eingeben (max. 8 Stellen): " );
  16.       scanf( "%s", buf );
  17.     }
  18.     while ( !sscanf( buf, "%d", &id ) || strlen( buf ) > 8 );
  19.  
  20.     if ( id == 0 )
  21.     {
  22.       break;
  23.     }
  24.  
  25.     int i = 2, k;
  26.     for ( k = strlen( buf ); k > 0; k-- )
  27.     {
  28.       printf( "%d: %d\n", i, buf[ k - 1 ] );
  29.       i++;
  30.     }
  31.  
  32.     int result = 0;
  33.     printf( "%d", result );
  34.   }
  35.  
  36.   return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement