C Programming Tutorial

 
 
 
 

Image

#include <stdio.h>
#include <conio.h>
void main(){
     int i,j,k,m,num,c;
     clrscr();
     printf(\"*****Logical Square*****\\n\");
     printf(\"Enter number of lines u want : \");
     scanf(\"%d\",&num);
     printf(\"\\n\\n\");
//for top part
      for(i=1;i<num;i++){
     c=num;
     for(j=1;j<=(num-i)+2;j++)
        putchar(\' \');
     for(k=1;k<=i;k++)
        printf(\"%d\",c--);
     c++;
     for(m=c;m<num;m++){
        printf(\"%d\",++c);
     }
     printf(\"\\n\");
     }

//for bottom part
      for(i=1;i<=num;i++){
     c=num;
     for(j=num;j>=(num-i);j--)
        putchar(\' \');
     for(k=c;k>i;k--)
        printf(\"%d\",k);
     for(m=k;m<=c;m++)
        printf(\"%d\",m);
     printf(\"\\n\");
     }

getch();
}

 
 
Didn't find what you were looking for? Find more on Program to display dimond triangle