Q. Write a C program to print following number rhombus.
1
121
12321
1234321
123454321
1234321
12321
121
1
Ans.
/*c program for number rhombus structure*/
#include<stdio.h>
#include<conio.h>
int main()
{
int num,r,c,sp;
printf("Enter number of rows : ");
scanf("%d",&num);
for(r=1; r<=num; r++)
{
for(sp=num-r; sp>=1; sp--)
printf(" ");
for(c=1; c<=r; c++)
printf("%d",c);
for(c=r-1; c>=1; c--)
printf("%d",c);
printf("\n");
}
for(r=1; r<=num; r++)
{
for(sp=r; sp>=1; sp--)
printf(" ");
for(c=1; c<=(num-r); c++)
printf("%d",c);
for(c=num-r-1; c>=1; c--)
printf("%d",c);
printf("\n");
}
getch();
return 0;
}
You might also like to read:
1
121
12321
1234321
123454321
1234321
12321
121
1
Ans.
/*c program for number rhombus structure*/
#include<stdio.h>
#include<conio.h>
int main()
{
int num,r,c,sp;
printf("Enter number of rows : ");
scanf("%d",&num);
for(r=1; r<=num; r++)
{
for(sp=num-r; sp>=1; sp--)
printf(" ");
for(c=1; c<=r; c++)
printf("%d",c);
for(c=r-1; c>=1; c--)
printf("%d",c);
printf("\n");
}
for(r=1; r<=num; r++)
{
for(sp=r; sp>=1; sp--)
printf(" ");
for(c=1; c<=(num-r); c++)
printf("%d",c);
for(c=num-r-1; c>=1; c--)
printf("%d",c);
printf("\n");
}
getch();
return 0;
}
/**************************************************
The output of above program would be:
**************************************************/
Figure: Screen shot of Number rhombus C program |
You might also like to read:
1
ReplyDelete1 2
1 2 3
1 2 3 4
1 2 3
1 2
1
Your above program source code at:
Deletehttp://cprogrammingcodes.blogspot.in/2012/07/number-triangle_28.html
A B C D E F E D C B A
ReplyDeleteA B C D E E D C B A
A B C D D C B A
A B C C B A
A B B A
A A
Your above character pyramid programs source code:
Deletehttp://www.cprogrammingcodes.blogspot.in/2012/09/character-pyramid.html
what does sp means?
ReplyDeletesp represent space.
DeleteIt is easily to remember that what is the working of specific variable.
Hey there, i saw this rhombus program and it is working great, i was wondering if you could give the explanation of the source code in comments? If you have time ofc. thx
ReplyDelete1
ReplyDelete121
12321
1234321
please send me this codeing
@Ashish,
DeleteYour required Vertical Continues Number Pyramid C program at :
http://cprogrammingcodes.blogspot.in/2013/08/number-triangle-design_23.html
1
ReplyDelete2 3
4
5 6
7
8 9
10
@sri surya,
DeleteYour required Vertical Continues Number Pyramid C program at :
http://cprogrammingcodes.blogspot.in/2013/08/vertical-continues-number-pyramid.html
program for this
ReplyDelete0
1 0 1
2 1 0 1 2
3 2 1 0 1 2 3
4 3 2 1 0 1 2 3 4
5 4 3 2 1 0 1 2 3 4 5
4 3 2 1 0 1 2 3 4
3 2 1 0 1 2 3
2 1 0 1 2
1 0 1
0
//fb/sheoran.dinesh
Delete#include
#include
void main()
{
int i,j,k,l,m,n;
clrscr();
for(i=0;i<=5;i++)
{
for(j=i;j>=0;j--)
{
printf("%d",j);
}
for(k=1;k<=i;k++)
{
printf("%d",k);
}
printf("\n");
}
//printf("\n\n");
for(l=4;l>=0;l--)
{
for(m=l;m>=0;m--)
{
printf("%d",m);
}
for(n=1;n<=l;n++)
{
printf("%d",n);
}
printf("\n");
}
getch();
}
how to make this programme in two veriable ???
ReplyDeletefor ex.:
int i,j;
@Harsh Makawana,
DeleteYou can make above number rhombus C program using only 2 integer variable,
as you can input the int num value already before the compile of program and each loop int value has own life and scope so just uses inner loop same int variable.
Hope its help you.
how about the inputted number is the side of the rhombus??? send me pls..
ReplyDeletei want this program .
ReplyDelete1 1
1 2 2 1
1 2 3 3 2 1
1 2 2 1
1 1
if the value of n is 4 the output shoild be in the form of 1234321.
ReplyDeleteand should use only one for foor or while loof.
hint:can use if loop inside for loop.
1
ReplyDelete1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
2 3 4 5 4 3 2
3 4 5 4 3
4 5 4
5
Please help me for this...