Follow on Facebook

Like and Share on Facebook

Monday, February 16, 2015

How to Print Pattern 1 23 456 78910 1112131415 in C


#include <stdio.h>
#include <conio.h>

void int rows, a,  b, number = 1;
printf("Number of rows of Floyd's triangle to print:");

scanf("%d",&rows);
for ( a = 1 ; a <= rows ; a++ ) {
for ( b = 1 ; b <= a ; b++ ) {
printf("%d ", number);
number++;
}
printf("\n");
}
}

Output:

1
23
456
78910
1112131415

No comments:

Post a Comment