training

Code I wrote during training
git clone git://git.bitsmanent.org/training
Log | Files | Refs | README

getsquare2.c (550B)


      1 /* Esercizio 5.20 */
      2 
      3 #include <stdio.h>
      4 
      5 void square(int, int);
      6 
      7 int main()
      8 {
      9    int n, c;
     10 
     11    printf("Give me the side: ");
     12    scanf("%d", &n);
     13 
     14    getchar(); /* take newline and, of course, ignore it */
     15 
     16    printf("Give me the character: ");
     17    c = getchar();
     18 
     19    square(n, c);
     20 
     21    return 0;
     22 } /* E0F main */
     23 
     24 /* Print a square of "side" size */
     25 void square(int side, int fillCharacter)
     26 {
     27    int i, j;
     28 
     29    for(i = side; i >= 1; i--) {
     30       for(j = side; j >= 1; j--)
     31 	 printf("%c", fillCharacter);
     32       printf("\n");
     33    }
     34 
     35 } /* eof square() */
     36