Why don't you figure out a way to print spaces if this following one is what you want:
In C:
PHP Code:
#include <stdio.h>
int main(int argc, char **argv) {
int n = 5, i, j;
printf("Enter no. of rows: ");
scanf("%d", &n);
for(i=1; i<n; i++) {
for(j=0; j<n-i+1; j++) { printf(" "); }
for(j=0; j<(2*i)-1; j++) { printf("c"); }
printf("\n");
}
for(i=n; i>0; i--) {
for(j=n-i+1; j>0; j--) { printf(" "); }
for(j=(2*i)-1; j>0; j--) { printf("c"); }
printf("\n");
}
return 0;
}
There are no online C "compilers", but a useful, limited interpreter might be found
here.
Output of vamsi360's program:
Code:
c
c c
c c c
c c c c
c c c c c