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 :
Output :
Program 4 :
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 :
Output :
Program 7 :
Output :
Program 8 :
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 :
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 :
Output :
Program 14 :
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 :
Output :
Program 18 :
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 :
Output :
Program 21 :
Output :
Program 22 :
Output :
Program 23 :
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”);
}
}