/* Program Name: sample0.c written by : Adnan El-Nasan Objective : how to use getchar(), and putchar(). Usage : waits for an input from user. if input = q or Q -> quits; if input in [0..9] -> '0..9' is printed out; if input in [a..z] -> 'a..z' is printed out; if input in [A..Z] -> 'A..Z' is printed out; */ #include #include main() { int i,input; while(1) /* forever */ { input = getchar(); /* read input key */ if(input=='q') exit(1); /* either quit or */ if( (input>='0')&&(input<='9') ) /* print sequence */ { for(i=48; i<58; i++) putchar(i); putchar('\n'); /* CR/LF */ } if( (input>='A')&&(input<='Z') ) { for(i=65; i<91; i++) putchar(i); putchar('\n'); } if( (input >='a')&&(input<='z') ) { for(i=97; i<123; i++) putchar(i); putchar('\n'); } } }