50. Heart Shape using *'s as shown below.
Thursday, February 4, 2016
Posted by Unknown
Tag :
Star Patterns
Ans:
#include <stdio.h>
int main()
{
int i, j, n;
printf("Enter value of n : ");
scanf("%d", &n);
for(i=n/2; i<=n; i+=2)
{
for(j=1; j<n-i; j+=2)
{
printf(" ");
}
for(j=1; j<=i; j++)
{
printf("*");
}
for(j=1; j<=n-i; j++)
{
printf(" ");
}
for(j=1; j<=i; j++)
{
printf("*");
}
printf("\n");
}
for(i=n; i>=1; i--)
{
for(j=i; j<n; j++)
{
printf(" ");
}
for(j=1; j<=(i*2)-1; j++)
{
printf("*");
}
printf("\n");
}
return 0;
}
int main()
{
int i, j, n;
printf("Enter value of n : ");
scanf("%d", &n);
for(i=n/2; i<=n; i+=2)
{
for(j=1; j<n-i; j+=2)
{
printf(" ");
}
for(j=1; j<=i; j++)
{
printf("*");
}
for(j=1; j<=n-i; j++)
{
printf(" ");
}
for(j=1; j<=i; j++)
{
printf("*");
}
printf("\n");
}
for(i=n; i>=1; i--)
{
for(j=i; j<n; j++)
{
printf(" ");
}
for(j=1; j<=(i*2)-1; j++)
{
printf("*");
}
printf("\n");
}
return 0;
}
Ans:
#include<stdio.h>
int main()
{
int i,j,k,l,m,n,o,p,q,r,s,t;
printf("\n\n\n\n\n");
for(i=0;i<15;i++)
printf(" ");
printf("* *\n");
for(j=0;j<13;j++)
printf(" ");
printf("* * * *\n");
for(k=0;k<11;k++)
printf(" ");
printf("* * * *\n");
for(l=0;l<11;l++)
printf(" ");
printf("* * * *\n");
for(m=0;m<11;m++)
printf(" ");
printf("* * *\n");
for(n=0;n<11;n++)
printf(" ");
printf("* *\n");
for(o=0;o<12;o++)
printf(" ");
printf("* *\n");
for(p=0;p<13;p++)
printf(" ");
printf("* *\n");
for(q=0;q<14;q++)
printf(" ");
printf("* *\n");
for(r=0;r<15;r++)
printf(" ");
printf("* *\n");
for(s=0;s<17;s++)
printf(" ");
printf("* *\n");
for(t=0;t<20;t++)
printf(" ");
printf("**\n");
return 0;
}
int main()
{
int i,j,k,l,m,n,o,p,q,r,s,t;
printf("\n\n\n\n\n");
for(i=0;i<15;i++)
printf(" ");
printf("* *\n");
for(j=0;j<13;j++)
printf(" ");
printf("* * * *\n");
for(k=0;k<11;k++)
printf(" ");
printf("* * * *\n");
for(l=0;l<11;l++)
printf(" ");
printf("* * * *\n");
for(m=0;m<11;m++)
printf(" ");
printf("* * *\n");
for(n=0;n<11;n++)
printf(" ");
printf("* *\n");
for(o=0;o<12;o++)
printf(" ");
printf("* *\n");
for(p=0;p<13;p++)
printf(" ");
printf("* *\n");
for(q=0;q<14;q++)
printf(" ");
printf("* *\n");
for(r=0;r<15;r++)
printf(" ");
printf("* *\n");
for(s=0;s<17;s++)
printf(" ");
printf("* *\n");
for(t=0;t<20;t++)
printf(" ");
printf("**\n");
return 0;
}
48.Star Shape using *'s as shown below.
Wednesday, February 3, 2016
Posted by Unknown
Tag :
Star Patterns
SmeleBD |
Ans:
#include<stdio.h>
int main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=16;j>=i;j--)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf(" *");
}
printf(" \n");
}
for(i=1;i<=6;i++)
{
for(j=1;j<=i;j++)
{
printf(" ");
}
for(j=16;j>=i;j--)
{
printf(" *");
}
printf("\n");
}
//////////////////////////////////////
for(i=12;i<=16;i++)
{
for(j=17;j>i;j--)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf(" *");
}
printf("\n");
}
////////////////////////////////////////////
for(i=5;i>=1;i--)
{
for(j=16;j>=i;j--)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf(" *");
}
printf(" \n");
}
}
int main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=16;j>=i;j--)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf(" *");
}
printf(" \n");
}
for(i=1;i<=6;i++)
{
for(j=1;j<=i;j++)
{
printf(" ");
}
for(j=16;j>=i;j--)
{
printf(" *");
}
printf("\n");
}
//////////////////////////////////////
for(i=12;i<=16;i++)
{
for(j=17;j>i;j--)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf(" *");
}
printf("\n");
}
////////////////////////////////////////////
for(i=5;i>=1;i--)
{
for(j=16;j>=i;j--)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf(" *");
}
printf(" \n");
}
}
Ans:
#include<iostream>
using namespace std;
int main()
{
cout<<"Enter size of Daimond: ";
int size;
cin>>size;
int z=1;
for ( int i=0; i<=size; i++)
{
for (int j=size; j>i; j--)
{
cout<<" "; // printing space here
}
cout<<"*"; // printing asterisk here
if ( i>0)
{
for ( int k=1; k<=z; k++)
{
cout<<" ";
}
z+=2;
cout<<"*";
}
cout<<endl; // end line similar to \n
}
z-=4;
for (int i=0; i<=size-1; i++)
{
for (int j=0; j<=i; j++)
{
cout<<" ";
}
cout<<"*";
for (int k=1; k<=z; k++)
{
cout<<" ";
}
z-=2;
if (i!=size-1)
{
cout<<"*";
}
cout<<endl;
}
return 0;
}
Ans:
#include<stdio.h>
int main()
{
int n=5,r,c;
for(r=1; r<=6; r++,n--)
{
/*first pyramid*/
for(c=1; c<=n; c++)
printf(" #");
/*second pyramid*/
for(c=1; c<=r; c++)
{
if(c==1)
printf(" *");
else
printf(" #");
}
/*third pyramid*/
for(c=r; c>1; c--)
{
if(c==2)
printf(" *");
else
printf(" #");
}
/*fourth pyramid*/
for(c=n; c>=1; c--)
printf(" #");
printf("\n");
}
getch();
return 0;
}
int main()
{
int n=5,r,c;
for(r=1; r<=6; r++,n--)
{
/*first pyramid*/
for(c=1; c<=n; c++)
printf(" #");
/*second pyramid*/
for(c=1; c<=r; c++)
{
if(c==1)
printf(" *");
else
printf(" #");
}
/*third pyramid*/
for(c=r; c>1; c--)
{
if(c==2)
printf(" *");
else
printf(" #");
}
/*fourth pyramid*/
for(c=n; c>=1; c--)
printf(" #");
printf("\n");
}
getch();
return 0;
}