Star Pattern Printing Programs in C (SET 2)

star pattern in C :: futureX

PROGRAM 1

   *
  * *
 * * *
* * * *

--------------------------------

#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,l;
printf("enter value of k");
scanf("%d",&k);

for(i=k;i>0;i--)
{
for(l=(i-1);l>0;l--)

{printf(" ");

}
for(j=i;j<=k;j++){
printf("*");
printf(" ");
}
printf("\n");

}
}



PROGRAM 2


    *
   * *
  *   *
 *     *
*       *

--------------------------------



#include<stdio.h>              
#include<conio.h>
void main()
{
int h,i,j,k;
clrscr();
printf("Enter the value");
scanf("%d",&k);
for(h=1;h<k;h++)
printf(" ");
printf("*\n");

for(i=0;i<(k-1);i++)
{for(j=i;j<(k-2);j++)
printf(" ");
printf("*");
for(j=0;j<(2*i+1);j++)
printf(" ");
printf("*\n");
}

getch();
}

0 comments:

Star Pattern Printing Programs in C (SET 1)


PROGRAM 1              
star pattern in C :: futureX


*
**
***
****
*****
******

--------------------------------


#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k;
printf("Enter the value");
scanf("%d",&k);
for(i=0;i<k;i++)
{for(j=0;j<=i;j++)
{printf("*");
}printf("\n");
}
}


PROGRAM 2


****
***
**
*

--------------------------------


#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k;
printf("Enter the value");
scanf("%d",&k);
for(i=k;i>0;i--){
for(j=i;j>0;j--)
{printf("*");
}printf("\n");
}
}

PROGRAM 3


*
**
***
****
***
**
*

--------------------------------




#include<stdio.h>
#include<conio.h>
void main()
{int l;
int i,j,k;
printf("Enter the value");
scanf("%d",&k);
for(i=0;i<k;i++)
{for(j=0;j<=i;j++)
{printf("*");
}printf("\n");
}

for(i=(k-1);i>0;i--){
for(l=i;l>0;l--)
{printf("*");
}printf("\n");
}
}





0 comments:

Copyright © 2013 futureX | Blogger Template by Clairvo