| CSC 161 | Grinnell College | Spring, 2012 |
| Imperative Problem Solving and Data Structures | ||
As a basic program about nested loops, consider the following code that prints rows with increasing numbers of asteriskes. Commentary after the program explains each element of this program.
#include <stdio.h>
int
main()
{
int i, j;
printf("Program to print rows with increasing numbers of asterisks.\n");
for (i = 1; i < 11; i++)
{
for (j = 0; j < i; j++)
{
printf("*");
}
printf("\n");
}
return 0;
}
asterisk-loop.c programThis document is available on the World Wide Web as
http://www.cs.grinnell.edu/~
|
created 28 July 2011 by April O'Neill last revised 29 July 2011 by April O'Neill |
|
| For more information, please contact Henry M. Walker at walker@cs.grinnell.edu. |