/* * draw a 'ruler' columns wide on 'stdout' * invoke as: * ruler n * or * ruler (default 80) * * I don't remember if I acquired this, wrote it, or translated * it from another language. H.Moran */ main(argc,argv) int argc; char *argv[]; { register i, width; switch ( argc ) { case 1: width = 80; break; case 2: width = atoi(argv[1]); break; default: puts("usage:\n\truler [n] (default 80)"); exit(); } for ( i = 0 ; i < width ; ++i ) putchar( (i % 10 == 0) ? '+' : '-' ); putchar('\n'); for ( i = 0 ; i < width ; ++i ) ( i % 10 == 0 ) ? putchar((i%100)/10 + '0') : putchar(' '); putchar( '\n' ); for ( i = 0 ; i < width ; ++i ) putchar( i % 10 + '0'); putchar('\n'); for ( i = 0 ; i < width ; ++i ) putchar ( (i % 10 == 0) ? '+' : '-' ); putchar('\n'); }