* *** ***** ******* *********
#include <stdio.h>
int main()
{
int i, j, k;
for(i=1;i<=5;i++)
{
for(j=i;j<5;j++)
{
printf(" ");
}
for(k=1;k<(i*2);k++)
{
printf("*");
}
printf("\n");
}
return 0;
}
Related Links:
- More Number Pattern Programs
- Star Pattern Programs in C
- Alphabet Pattern Programs in C
- Series Programs in C
good programming, easy to understand!!1
ReplyDeletei love this blog.............
ReplyDeleteall wrong codes!!!!!!!!!!!!!!!
ReplyDeleteThis code is tested on codepad. check this link http://codepad.org/YQSAu3Lq
DeleteYES, ITS CORRECT.
DeleteWrong code
ReplyDeleteas i said before this code is verified at codepad.ora, check following link
Deletehttp://codepad.org/YQSAu3Lq
wrong
Deletecheck the output on http://codepad.org/YQSAu3Lq
Deleteno its working its coming but not in a triangle shape but in a half triangle
Delete#include
ReplyDeleteint main()
{
int i, j, k;
for(i=1;i<=5;i++)
{
for(j=n-i;j>=1;j--)
{
printf(" ");
}
for(k=1;k<(2*n-1);k++)
{
printf("*");
}
printf("\n");
}
return 0;
}
What is 'n' here?
Deleteits \n, new line
Delete@nimish-I can understand that :)
Delete@Avinash- What is 'n' in --> "for(k=1;k<(2*n-1);k++)" ??
#include
Deleteint main()
{
int i, j;
for(i=1;i<=5;i++)
{
for(j=1;j<=9;j++)
{
if(J>=6-i && j<=4+i)
{
print("*");
}
else
{
printf(" ");
}
}
printf("\n");
}
the code is wrong buddy
ReplyDeletecheck running version of this code at http://codepad.org/YQSAu3Lq
DeleteCheck out this code for input of any no of rows:
ReplyDelete#include
void main()
{
int i,j,k,n;
printf("Enter the no of rows \n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=n;j>i;j--)
{
printf(" ");
}
for(k=1;k<=i*2-1;k++)
{
printf("*");
}
printf("\n");
}
}
you have written the same code,moreover you have rather added few characters to make it cumbersome..
Deletethis code is right I executed it and successfully got output. please explain it line by line doing specially for(k=1;k<=i*2-1;k++) this loop
ReplyDeletethis blog is perfect and the 1st code is very easy to understand.
ReplyDeleteTry this one.
ReplyDelete#include
int main()
{
int i,j,n;
printf("Enter a value=\n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=n-i;j++)
printf(" ");
for(j=1;j<=2*i-1;j++)
printf("*");
printf("\n");
}
//printf("\n");
return 0;
}
wrong\ code
ReplyDeleteare you mad...
DeleteAbe chutiya hai kya ..ek line ka code ata nahi aur chala ata hai ..wrong batane ..stop buzzing unnecessarily
DeleteGreat...
ReplyDeleteDear anonymous, we got that it's wrong code than why don't you provide the right code instead of captioning wrong code at every comment. Plz provide soln not suggestions or statements. 😊
ReplyDeleteThe code is working fine :) thanks
ReplyDeletehow you are managing spaces in the pattern?
ReplyDeletein the third loop there should be 2*i-1.That,s it and every thing is fucking fine
ReplyDeleteWhat you said was right dude. ��
DeleteMain()
ReplyDelete{int I, j;
for(I=0;I<=4;I++)
for(j=4-I; j<=4+I; j++)
Printf("*");
}
can you describe the logic of the program
ReplyDeleteGreat blog ! Keep it up.
ReplyDeleteBrother Use GDB ONLINE COMPILER
ReplyDelete#include
ReplyDeletevoid main()
{
int i,j,k,l;
for(i=1;i<=5;i++)
{
for(k=5;k>i;k--)
{
printf(" ");
}
for(j=1;j<(i*2);j++)
printf("*");
puts("");
}
}
#include
ReplyDeletevoid main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=9;j++)
{
if(j>=6-i && j<=4+i)
{
printf("*");
}else{
printf(" ");
}
}
printf("\n");
}
}
Advanced Level Star Pattern Programs In Java
ReplyDeleteRead Now
Why can't the output is a bit wierd when n=6 or above try first
ReplyDeleteIgnore why can't accidently written
ReplyDelete