Page 1 of 212> Show 40 post(s) from this thread on one page

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Floyd's triangle (http://www.go4expert.com/forums/floyds-triangle-t13168/)

 Amit Kumar Saha 23Aug2008 08:27

Friends,

How can I control the increment of variable in floyd triangle. And I how should I initialize?

another optional problem what is cycle length between and including two int number.

Amit
:nice:

 xpi0t0s 26Aug2008 03:45

Re: Floyd's triangle

I'm not really sure what you mean. I'd use three variables for that, one containing the current number, one containing the number of numbers in the current line, and the third would be a loop from 0 to the second. Probably something like:
Code:

```int i=1, j=1; for (k=0; k<j; k++)   printf("%d ",i++); printf("\n"); j++;```

 xpi0t0s 26Aug2008 12:25

Re: Floyd's triangle

I'm not really sure what you mean. I'd use three variables for that, one containing the current number, one containing the number of numbers in the current line, and the third would be a loop from 0 to the second (plus some sort of bailout condition). Probably something along the following lines:
Code:

```int i=1, j=1 for k=0..j   printf(i++) printf("\n") j++```

 balaje26 16Sep2008 21:43

Re: Floyd's triangle

Floyds triangle full program...?

 Amit Kumar Saha 17Sep2008 01:11

Re: Floyd's triangle

yes,
Many thanks for showing interest.

 Amit Kumar Saha 17Sep2008 01:22

Re: Floyd's triangle

brothers,

plz don't mind I have forgot how to start a new thread. Plz pardon me for this.

help me in this problem first.

 oogabooga 17Sep2008 06:12

Re: Floyd's triangle

To recap, something like this:
Code:

```  int column, line, n = 1;   for (line = 0; line < number_of_lines; ++line) {     for (column = 0; column <= line; ++column)       printf ("%3d ", n++);     printf ("\n");   }```

 balaje26 17Sep2008 20:34

Re: Floyd's triangle

how to learn c easy

 xpi0t0s 17Sep2008 22:08

Re: Floyd's triangle

Get someone else to do it. Programming is HARD.

```import java.util.*; import java.math.*; import java.io.*; public class pyramid{  public static void main(String argsp[]){                 int i=1,j;                 int num = 1;                 while(num<=91){                         for(j=1; j<=i; j++){                                 System.out.print (num + " ");                                 num++;                                                         }                 i++;                 System.out.print("\n");                                        }         } }```