From 9388dda25cc726627a8224e4a542e4517468eb12 Mon Sep 17 00:00:00 2001 From: sharan sk <46704651+sharansk792000@users.noreply.github.com> Date: Sat, 12 Oct 2019 23:12:57 +0530 Subject: [PATCH] Create program42.c --- C/program42/program42.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 C/program42/program42.c 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); +}