diff --git a/C/program42/program42.c b/C/program42/program42.c new file mode 100644 index 00000000..5a6154b0 --- /dev/null +++ b/C/program42/program42.c @@ -0,0 +1,17 @@ +/*C Program to print Floyd’s triangle*/ +// Without using a temporary variable and with only one loop +#include +void floyd(n){ + int i,j=1; + for (i=1;i<=(n*(n+1))/2;i++){ + printf("%d ",i); + if(i==(j*(j+1))/2){ + printf("\n"); + j++; + } + } +} + +int main(){ + floyd(6); +}