Tilted Forum Project Discussion Community  

Go Back   Tilted Forum Project Discussion Community > Interests > Tilted Technology


 
 
LinkBack Thread Tools
Old 11-30-2004, 12:04 PM   #1 (permalink)
Junkie
 
zero2's Avatar
 
[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.
zero2 is offline  
Old 11-30-2004, 12:14 PM   #2 (permalink)
Junkie
 
Stiltzkin's Avatar
 
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?
__________________
The most important thing in this world is love.

Last edited by Stiltzkin; 11-30-2004 at 12:17 PM..
Stiltzkin is offline  
Old 11-30-2004, 12:22 PM   #3 (permalink)
Tilted
 
kebo's Avatar
 
Location: reno,nv
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
kebo is offline  
Old 11-30-2004, 01:09 PM   #4 (permalink)
Junkie
 
zero2's Avatar
 
Thanks that works, I don't think I would of ever thought of doing it that way.
zero2 is offline  
 

Tags
loop


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 12:34 PM.

Tilted Forum Project

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, 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 41 42 43 44 45 46 47 48 49 50 51 52 53 54