spiral like pattern program in c


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main()
{

    int n,i,j,boundry,num;
    scanf("%d", &n);
boundry=(n*2)-1;
    for(i=0;i<boundry;i++){
     for(j=0;j<boundry;j++){
          if(i<j) num=i; else num=j;
         if(num>=boundry-i) num=boundry-i-1;
         if(num>=boundry-j-1) num=boundry-j-1;
         printf("%d ",n-num);
       
       //printf("sa");
    } 
        printf("\n");
    }
   
    return 0;
}

Comments

Popular posts from this blog

aaabb to32 ,aabbb to a2b3 convert in c-asr

a2b3 output aabbb c program and beautiful use of getchar() ,isdigit() ,atoi() functions and stdlib.h header file-asr

C program to print square spiral number pattern - asr