|
|
16Oct/110
Draw a “stdio” Square Shape C Source Code
Working in a one of biggest electronics manufacturer in the world that didn't make my training comes to advanced level. I've learn again from the bottom. Of course the language used is native-C which the founder passed away recently...
One of the simplest thing is using looping for drawing some shapes and in this post it will be a square shapes. The easiest shape i think. What we nee d just a nested loop for drawing the rows (outer loop) and the cell or column (inner loop) which loop with the same number (square has same size for width/column and height/row).
#include "stdio.h"
#include "conio.h"
int main()
{
int side;
printf("Square's Side Size: ");
scanf("%d", &side);
printf("\n");
//Row Generation
for (int i=0;i<side;i++)
{
//Column Generation
for (int j=0;j<side;j++)
{
//Print * at each cell
printf("*");
}
//Go to next row
printf("\n");
}
getch();
return 0;
}
That's all.... I'll post other shapes soon :D
Related posts:




