.
Previous Next

Write a C program which prints diamond format?

/* C program which prints diamond format */
#include<stdio.h>
#include<conio.h>
int main(){
    int i,j,number,rows = 9; /* give input here*/
    clrscr();
    for (i = 1; i <= rows; i++) {
    number = 1;
    gotoxy((rows-i+1)*2,i);
    for (j = 1; j <= i; j++) {
        printf("%4c",'*');
    }
    printf("\n");
    }
    for (i = rows; i > 0 ; i--) {
       int number = 1;
       gotoxy((rows-i+1)*2,rows*2-i);
       for (j = 1; j <= i; j++) {
           printf("%4c",'*');
       }
       printf("\n");
    }
    getch();
    return 0;
}

Previous Next