you are right, that does print a triangle
Thomas Hruska <[EMAIL PROTECTED]> wrote: Robert Ryan wrote:
> this gives me an infinite loop.... why? is it missing a bracket someplace
> bob
>
> #include<stdio.h>
> int main()
> {
> int tr=10,r,c,s, o=1;
>
> for(c=1; c<=tr; r++)
> {
> for(c=1;c<=tr- r;c++)
Probably because of these two loop statements. Take a closer look. You
probably meant:
for(r=1; r<=tr; r++)
{
for(c=1;c<=tr- r;c++)
> {
> printf(" ");
> }
> for(c=1;c<=o; s++)
And then this loop you probably meant:
for(s=1;s<=o; s++)
> printf("c");
> printf("\n") ;
> o=o+2;
> }
>
> }
The way you had set it up, c would constantly get reset - in particular,
by the second loop's initialization.
Using a debugger to step through code like this - pausing line-by-line
and analyzing the value of each variable - usually catches the majority
of such problems.
--
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197
*NEW* MyTaskFocus 1.1
Get on task. Stay on task.
http://www.CubicleSoft.com/MyTaskFocus/
---------------------------------
Never miss a thing. Make Yahoo your homepage.
[Non-text portions of this message have been removed]