![]() |
[C] For Loop
Im pretty much a beginner at this, and I just wanted to know if it is possible to
to print a series of astericks, such as the below design which I just made up, using the for loop. ** ** ** The structure of the for loop is: for (i=0; i <= limit; i++) The limit variable it would seem like it should be equal to 2, but then here' s where I get stuck, how do you compare a character such as the * to a limit which is an integer, it doesn't really make sense, so I was wondering if this possible, or if should I try some other alternative. |
for(i=0; i<3; i++)
printf("**\n"); That should work, but I just typed it up real quick without thinking too much. Also, why would you want to compare a character to an integer in the first place? |
expand on the code by Stilzkin
for(i=0; i<nRows; i++) { for(j =0;j<nCols; j++) printf("*"); prinrf("\n"); } pardon any syntax errors, my C is kinda rusty. Hope you get the idea kevin |
Thanks that works, I don't think I would of ever thought of doing it that way.
|
All times are GMT -8. The time now is 09:32 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project