********** **** **** *** *** ** ** * * ** ** *** *** **** **** **********
#include <stdio.h>
int main()
{
int i, j, k;
for(i=1;i<=5;i++)
{
for(j=1;j<=6-i;j++)
{
printf("*");
}
for(k=1;k<i;k++)
{
printf(" ");
}
for(j=1;j<=6-i;j++)
{
printf("*");
}
printf("\n");
}
for(i=2;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("*");
}
for(k=1;k<=5-i;k++)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
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
output is printing different pattern..Please verify the code
ReplyDeleteits working fine, check the codepad execution http://codepad.org/dWs0Cp2I
Deletefor(k=1;k<i;k++)
ReplyDelete{
printf(" ");
}
This above Segment should be added one more time below the same above segment.
i am using codepad.org for validating the code. please check http://codepad.org/Lf8I9vMj
Delete# include
ReplyDelete# include
void main()
{
clrscr();
int i,j,k;
for(i=1;i<=5;i++)
{
for(j=1;j<=6-i;j++)
{
cout<<"*";
}
for(k=1;k<((2*i)-1);k++)
{
cout<<" ";
}
for(j=1;j<=6-i;j++)
{
cout<<"*";
}
cout<<"\n";
}
for(i=4;i>=1;i--)
{
for(j=5;j>=i;j--)
{
cout<<"*";
}
for(k=1;k<((2*i)-1);k++)
{
cout<<" ";
}
for(j=5;j>=i;j--)
{
cout<<"*";
}
cout<<"\n";
}
getch();
}
the above code i tried is not working ...
i have made some modification in the code and it is working..
you can verify... :-)
This one is perfect!! The one by main author is not fitting in precisely to the problem. Although no credit away from him as its(this site) a pretty good job overall!! Cheers!!
Deletegud effort thanks a lottt..
DeleteThis is perfect program but in last pattern I face double space problem. So 2nd time use k<=((2*i)-1) as k<=((2*i)-2)
Deletealso
ReplyDeletefor(k=1;k<5-i;k++)
{
printf(" ");
}
include below the same segment
for(k=1;k<=5-i;k++)
ReplyDelete{
printf(" ");
}
k=1 is wrong it would be k=i.
instead it would be this will be 2 times
for(k=i;k<=5-i;k++)
{
printf(" ");
}
for(k=i;k<=5-i;k++)
{
printf(" ");
}
=$a && $j<=$b && $i!=1 && $i!=10)
ReplyDelete{
echo "@";
}
else
{
echo ".";
}
}
echo "\n";
}
for($i=5;$i>=1;$i--)
{
for($j=10;$j>=1;$j--)
{
$a=5-($i-2);
$b=5+($i-1);
if($j>=$a && $j<=$b && $i!=1 && $i!=10)
{
echo "v";
}
else
{
echo "~";
}
}
echo "\n";
}
?>
This generalized code is working fine!!
ReplyDelete#include
void main()
{
int i,j,k,n,l,m;
printf("Enter the number of rows: \n");
scanf("%d",&n);
for(i=1;i<=n/2;i++)
{
for(j=i;j<=n/2;j++)
{
printf("*");
}
for(k=1;kn/2;l--)
{
printf("*");
}
for(m=i+1;mn/2;l--)
{
printf("*");
}
printf("\n");
}
}
he has just printed double spaces with k variable in first half sequence, the code is fine.
ReplyDeletei want to code a rectangle of stars within a rectangle of stars can anybody help me thanks?
ReplyDelete#include
ReplyDeletevoid main()
{
int i,j,k;
for(i=1;i<=5;i++)
{
for(j=1;j<5;j++)
{
for(k=1,k<(i*2);k++)
{
printf("*");
}
}
}
}
can u tell d logic.
ReplyDeletethanks
This is generalized code:
ReplyDelete#include
#include
int main()
{
int row,colt,cols,n;
printf("No of rows:");
scanf("%d",&n);
for(row=1;row<=n/2+1;row++)
{
for(cols=n/2-row+2;cols>=1;cols--)
printf("*");
for(colt=n/2+1;colt>((n/2)+1-(row-1));colt--)
printf(" ");
for(colt=n/2+1;colt>((n/2)+1-(row-1));colt--)
printf(" ");
for(cols=n/2-row+2;cols>=1;cols--)
printf("*");
printf("\n");
}
for(row=n/2+1;row>=1;row--)
{
for(cols=n/2-row+2;cols>=1;cols--)
printf("*");
for(colt=n/2+1;colt>((n/2)+1-(row-1));colt--)
printf(" ");
for(colt=n/2+1;colt>((n/2)+1-(row-1));colt--)
printf(" ");
for(cols=n/2-row+2;cols>=1;cols--)
printf("*");
printf("\n");
}
return 0;
}
#include
ReplyDeleteint main()
{
int r,i,j,k,l,m,n,p;
printf("Enter the no. of rows (better be odd) : ");
scanf("%d",&r);
m = r/2+1;
n = r - m;
for(i=1;i<=r;i++)
{
if(i<=m)
{
for(j=1;j<=m-i+1;j++)
{
printf("*");
}
for(k=1;k<=2*(i-1);k++)
{
printf(" ");
}
for(l=1;l<=m-i+1;l++)
{
printf("*");
}
}
else
{
p = i-n;
for(j=1;j<=p;j++)
{
printf("*");
}
for(k=1;k<=(r+1)-(2*p);k++)
{
printf(" ");
}
for(l=1;l<=p;l++)
{
printf("*");
}
}
printf("\n");
}
return 0;
}
//it's working fine and its simple. try it...
ReplyDelete#include
using namespace std;
int main(){
int n;
cin>>n;
int k=-1;
for(int i=0;i<=n;i++)
{ i<=(n/2)?k++:k--;
for(int j=0;j<=n;j++){
if((j<=(n/2)-k)||(j>=(n/2)+k))
cout<<"* ";
else
cout<<" ";
}
cout<<"\n";
}
return 0;
}
#include
ReplyDeleteint main(){
int i,j,k,n;
printf("enter the number=");
scanf("%d",&n);
for(i=1;i<=n;i++){
for(j=1;j<=n+1-i;j++)
{
printf("*");
}
for(k=1;k<2*i-1;k++)
{
printf(" ");
}
for(j=1;j<=n+1-i;j++)
{
printf("*");
}
printf("\n");
}
for(i=2;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("*");
}
for(k=1;k<=2*(n-i);k++)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
return 0;
}
abinis_yu Kendra Belehar Download
ReplyDeleteandeesubsmea
rufiFbi_zaMadison Jonathan Mahfood PhotoGlory
ReplyDeleteBootstrap Studio
Corel Painter 2023 v23.0.0.244
Norton Security
conchandkana