Tilted Forum Project Discussion Community

Tilted Forum Project Discussion Community (https://thetfp.com/tfp/)
-   Tilted Technology (https://thetfp.com/tfp/tilted-technology/)
-   -   [C] For Loop (https://thetfp.com/tfp/tilted-technology/77413-c-loop.html)

zero2 11-30-2004 12:04 PM

[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.

Stiltzkin 11-30-2004 12:14 PM

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?

kebo 11-30-2004 12:22 PM

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

zero2 11-30-2004 01:09 PM

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 05:36 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


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40