1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
#include<stdio.h>
int main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=5;j>i;j--)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("%d ",j);
}
printf("\n");
}
return 0;
}
Related Links:
- More Number Pattern Programs
- Star Pattern Programs in C
- Alphabet Pattern Programs in C
- Series Programs in C
wrng program
ReplyDeleteseems working for me, checkout on codepad
Deletehttp://codepad.org/lsaZQvbx
Seriously !!!!!!!!!!!!!!!!
ReplyDeletethe above program is wrong
It working on codepad.com http://codepad.org/lsaZQvbx
Deletethe program is true dude
Deletewhats wrng in it???
ReplyDelete#include
ReplyDeleteint main()
{
int i,j,s;
for(i=1;i<=5;i++)
{
printf("\n");
for(s=1;s<=5-i;s++)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("%d ",j);
}
}
return 0;
}
works perfectly on codeblocks
ReplyDeletewrng in it??
ReplyDeletewrong program
ReplyDeleteuse this code to get the pattern correctly
ReplyDeletemain()
{
int i,j,k;
for(i=1;i<=5;i++)
{
for(int k=5;k>=i;k--)
{
System.out.print(" ");
}
for(j=1;j<=i;j++)
{
System.out.print(j);
System.out.print(" ");
System.out.print(" ");
System.out.print(" ");
}
System.out.print("\n");
}
}
for (var i = 1; i <= n; i++) {
ReplyDeletefor (var j = i; j <= n; j++) {
result += " ";
}
for (var k = 1; k <= (i); k++) {
result += c+" ";
}
result += "\n";
}
return result;
If you are using "Turbo C" then jst use **printf("%2d ",j);** instead of
ReplyDelete**printf("%d ",j);**
Thanks dada
Deleteit is wrong....
ReplyDeleteThis program is 100℅ right
ReplyDelete