C Program to Print All Number Pattern Program

These are just a few examples of the many different number patterns that can be found in C program. By understanding these patterns, you can write more efficient and concise code.

Program 1 :

#include<stdio.h>
#include<stdio.h>
int main()
{
int x,n;
printf(“Enter the Value : “);
scanf(“%d”,&n);
for(x=1;x<=n;x++)
{
printf(“\n%d”,x);
}
return 0;
}

Output :

Program 2 :

#include<stdio.h>
#include<stdio.h>
int main()
{
int x,n;
printf(“Enter the Value : “);
scanf(“%d”,&n);
for(x=1;x<=n;x++)
{
printf(” %d “,x);
}
return 0;
}

Output :

Program 3 :

#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,n;
printf(“Enter the Value : “);
scanf(“%d”,&n);
for(x=1;x<=n;x++)
{
for(y=1;y<=n;y++)
{
printf(” %d”,x);
        }
        printf(“\n”);
}
}

Output :

Program 4 :

#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z,n;
printf(“Enter the Value : “);
scanf(“%d”,&n);
for(x=n;x>=-n;x–)
{
for(y=1;y<=abs(x);y++)
{
printf(” “);
        }
        for(z=n;z>=abs(x);z–)
{
printf(“%d”,z);
        }
        printf(“\n”);
}
}

Output :

Program 5 :

#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,n,m;
printf(“Enter the Value : “);
scanf(“%d”,&n);
m=n/2+1;
for(x=1;x<=n;x++)
{
for(y=1;y<=n;y++)
{
if(x==m||y==m)
{
printf(“%d”,m-abs(x-y));
}
else
{
printf(” “);
}
}
printf(“\n”);
}
}

Output :

Program 6 :

#include<stdio.h>
#include<stdio.h>
int main()
{
int x,y,n;
printf(“Enter the Value : “);
scanf(“%d”,&n);
for(x=1;x<=n;x++)
{
for(y=1;y<=x;y++)
{
printf(“%d”,y);
        }
        printf(“\n”);
}
}

Output :

Program 7 :

#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,n;
printf(“Enter the Value : “);
scanf(“%d”,&n);
for(x=1;x<=n;x++)
{
for(y=n;y>=x;y–)
{
printf(“%d”,y);
        }
        printf(“\n”);
}
}

Output :

Program 8 :

#include<stdio.h>
#include<stdio.h>
int main()
{
int x,y,n;
printf(“Enter the Value : “);
scanf(“%d”,&n);
for(x=1;x<=n;x++)
{
for(y=n;y>=x;y–)
{
printf(“%d”,x);
        }
        printf(“\n”);
}
}

Output :

Program 9 :

#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,n,m;
printf(“Enter the Value : “);
scanf(“%d”,&n);
m=n/2+1;
for(x=1;x<=n;x++)
{
for(y=1;y<=n;y++)
{
if(x==m||y==m)
{
printf(“%d”,m-abs(x-y));
}
else
{
printf(” “);
}
}
printf(“\n”);
}
}

Output :

Program 10 :

#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,n,z;
printf(“Enter the Value : “);
scanf(“%d”,&n);
for(x=1;x<=n;x++)
{
for(y=n-1;y>=x;y–)
{
printf(” “);
        }
        for(z=1;z<=x;z++)
{
printf(“%d”,z);
        }
        printf(“\n”);
}
}

Output :

Program 11 :

#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,n,m;
printf(“Enter the Value : “);
scanf(“%d”,&n);
m=n/2+1;
for(x=1;x<=n;x++)
{
for(y=1;y<=n;y++)
{
if(x==m||y==m)
{
printf(“%d”,m-abs(x-y));
}
else
{
printf(” “);
}
}
printf(“\n”);
}
}

Output :

Program 12 :

#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,n,m;
printf(“Enter the Value : “);
scanf(“%d”,&n);
m=n/2+1;
for(x=1;x<=n;x++)
{
for(y=1;y<=n;y++)
{
if(x==m||y==m)
{
printf(“%d”,m-abs(x-y));
}
else
{
printf(” “);
}
}
printf(“\n”);
}
}

Output :

Program 13 :

#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,n;
printf(“Enter the Value : “);
scanf(“%d”,&n);
for(x=n;x>=1;x–)
{
for(y=1;y<=x;y++)
{
printf(“%d”,y);
        }
        printf(“\n”);
}
}

Output :

Program 14 :

#include<stdio.h>
#include<stdio.h>
int main()
{
int x,y,n;
printf(“Enter the Value : “);
scanf(“%d”,&n);
for(x=n;x>=1;x–)
{
for(y=1;y<=x;y++)
{
printf(“%d”,x);
        }
        printf(“\n”);
}
}

Output :

Program 15 :

#include<stdio.h>
#include<conio.h>
main()
{
int x,y,n;
printf(“Enter the Value : “);
scanf(“%d”,&n);
for(x=1;x<=n;x++)
{
for(y=1;y<=n*2-1;y++)
{
if(y<=x||y>n*2-1-x)
{
printf(“%d”,y);
}
else
{
printf(” “);
}
}
printf(“\n”);
}
}

Output :

Program 16 :

#include<stdio.h>
#include<conio.h>
main()
{
int x,y,n;
printf(“Enter the Value : “);
scanf(“%d”,&n);
for(x=1;x<=n;x++)
{
for(y=1;y<=n*2-1;y++)
{
if(y<=x||y>n*2-1-x)
{
printf(“%d”,x);
}
else
{
printf(” “);
}
}
printf(“\n”);
}
}

Output :

Program 17 :

#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z,n;
printf(“Enter the Value : “);
scanf(“%d”,&n);
for(x=1;x<=n;x++)
{
for(y=n-1;y>=x;y–)
{
printf(” “);
        }
        for(z=1;z<=x;z++)
{
printf(“%d “,x);
        }
        printf(“\n”);
}
}

Output :

Program 18 :

#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z,n;
printf(“Enter the Value : “);
scanf(“%d”,&n);
for(x=1;x<=n;x++)
{
for(y=n-1;y>=x;y–)
{
printf(” “);
        }
        for(z=1;z<=x;z++)
{
printf(“%d “,z);
        }
        printf(“\n”);
}
}

Output :

Program 19 :

#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,n,m;
printf(“Enter the Value : “);
scanf(“%d”,&n);
m=n/2+1;
for(x=1;x<=n;x++)
{
for(y=1;y<=n;y++)
{
if(x==m||y==m)
{
printf(“%d”,m-abs(x-y));
}
else
{
printf(” “);
}
}
printf(“\n”);
}
}

Output :

Program 20 :

#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z,n;
printf(“Enter the Value : “);
scanf(“%d”,&n);
for(x=5;x>=1;x–)
{
for(y=4;y>=x;y–)
{
printf(” “);
        }
        for(z=1;z<=x;z++)
{
printf(“%d “,z);
        }
        printf(“\n”);
}
}

Output :

Program 21 :

#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,n;
printf(“Enter the Value : “);
scanf(“%d”,&n);
for(x=n;x>=-n;x–)
{
for(y=n;y>=abs(x);y–)
{
printf(” %d “,y);
        }
        printf(“\n”);
}
}

Output :

Program 22 :

#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z,n;
printf(“Enter the Value : “);
scanf(“%d”,&n);
for(x=n;x>=-n;x–)
{
for(y=1;y<=abs(x);y++)
{
printf(” “);
        }
        for(z=n;z>=abs(x);z–)
{
printf(“%d”,y);
        }
        printf(“\n”);
}
}

Output :

Program 23 :

#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z,n;
printf(“Enter the Value : “);
scanf(“%d”,&n);
for(x=n;x>=-n;x–)
{
for(y=1;y<=abs(x);y++)
{
printf(” “);
        }
        for(z=n;z>=abs(x);z–)
{
printf(“%d”,z);
        }
        printf(“\n”);
}
}

Output :

Program 24 :

#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,n,m;
printf(“Enter the Value : “);
scanf(“%d”,&n);
m=n/2+1;
for(x=1;x<=n;x++)
{
for(y=1;y<=n;y++)
{
if(x==m||y==m)
{
printf(“%d”,m-abs(x-y));
}
else
{
printf(” “);
}
}
printf(“\n”);
}
}

Output :

Leave a Comment

Your email address will not be published.

Shopping Basket
Verified by MonsterInsights