#include <stdio.h> #include <stdlib.h> /* Puzzle A16 -- print a n by m block of stars */ int main(int argc, char *argv[]) { int row, col; int n=7, m=21; for ( row=0; row < n; row++ ) { for ( col=0; col < m; col++ ) printf("*"); printf("\n"); } system("PAUSE"); return 0; }
Comment:
This is your basic loop within a loop.
The outer loop (the counter is row
)
counts the rows.
The inner loop (the counter is col
)
counts the characters in the current row.