C Program to print Rhombus Pattern for upto n numbers.[Pattern 27]| Using C language| C Program series 48|
👨💻C Program to print Rhombus Pattern for upto n numbers. [Pattern:27]
Code :
For n number of LINES:
/*
C Program to print Rhombus Pattern for upto n numbers.[Pattern 27]
For Example:n=5
11
2 2
3 3
4 4
5 5
4 4
3 3
2 2
11
*/
#include<stdio.h>
main()
{
printf("C Program to print Rhombus Pattern for upto n numbers.[Pattern 27]\n\n");
int i,j,n;
printf("Enter number:");
scanf("%d",&n);
printf("==> Rhombus Pattern.\n");
for(i=1;i<=n;i++)
{
printf("\n\t");
for(j=n-i;j>0;j--)
{
printf(" ");
}
printf("%d",i);
if(i==1)
{
printf("%d",i);
}
for(j=1;j<=i-1;j++)
{
if(i>=2)
{
printf(" ");
}
if(j==i-1)
{
printf("%d",i);
}
}
}
for(i=1;i<n;i++)
{
printf("\n\t");
for(j=1;j<=i;j++)
{
printf(" ");
}
printf("%d",n-i);
if(i==n-1)
{
printf("%d",n-i);
}
for(j=n-i-1;j>0;j--)
{
printf(" ");
if(j==1)
{
printf("%d",n-i);
}
}
}
printf("\n");
}
The output of Code:

![C Program to print Rhombus Pattern for upto n numbers.[Pattern 27]](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_I2yDp9QPhoz_cOXDcBTQhMjm4kda2ZoONS_6B8rzWnNT9sf2Sy1YoG4HHMySvQf617AXorGsBFG9s8mxrHvoPyU9zqtElxitqCbEfHNEOCGgosS7u5TfdTOiLIyNARwEsGdHjpKuxD-2ytyImJgi5N3L17NnVq8SPZA1lcHGdLxijhYqc6Jba-E/w640-h302/Screenshot%202022-12-02%20224819.jpg)
![C Program to print Rhombus Pattern for upto n numbers.[Pattern 27]](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi842nz9FBBqvINqZGw139_76L2gLrAl4czu5hrel8h1qljdqGcd-h1MSpj1rmYh5Ru3SvVQahFhKRLmCbxp7sFPn-4CjUQ1G6E8ufFho3huSviJ9HBg680e9xWsfTljIL-ef4KrUcA17Lr2JINiAZWSFBTcWWKmxemnDHy9MNrg4gHGawglFevtHE/w640-h446/Screenshot%202022-12-02%20224853.jpg)
Comments
Post a Comment