Asterisk Programs.

#include <stdio.h>
 
int main()
{
  int n, c, k, space = 1;
 
  printf("Enter number of rows\n");
  scanf("%d", &n);
 
  space = n - 1;
 
  for (k = 1; k <= n; k++)
  {
    for (c = 1; c <= space; c++)
      printf(" ");
 
    space--;
 
    for (c = 1; c <= 2*k-1; c++)
      printf("*");
 
    printf("\n");
  }
 
  space = 1;
 
  for (k = 1; k <= n - 1; k++)
  {
    for (c = 1; c <= space; c++)
      printf(" ");
 
    space++;
 
    for (c = 1 ; c <= 2*(n-k)-1; c++)
      printf("*");
 
    printf("\n");
  }
 
  return 0;
}

OUTPUT :

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

#include <stdio.h>
 
int main()
{
  int n, c, k, space = 1;
 
  printf("Enter number of rows\n");
  scanf("%d", &n);
 
  space = n - 1;
 
  for (k = 1; k <= n; k++)
  {
    for (c = 1; c <= space; c++)
      printf(" ");
 
    space--;
 
    for (c = 1; c <= 2*k-1; c++)
      printf("*");
 
    printf("\n");
  }
 
  space = 1;
 
  for (k = 1; k <= n - 1; k++)
  {
    for (c = 1; c <= space; c++)
      printf(" ");
 
    space++;
 
    for (c = 1 ; c <= 2*(n-k)-1; c++)
      printf("*");
 
    printf("\n");
  }
 
  return 0;
}

OUTPUT :

Diamond c program

 

 

 

Asterisk #1

#include<stdio.h>
#include<conio.h>
void main()
{
 int row,i,j;
 clrscr();
 printf("Enter the number of rows you want: \n");
 scanf("%d",&row);
 for(i=1;i<=row;i++)
 {
 for(j=1;j<=i;j++)
 {
 printf("* ");
 }
 printf("\n");
 }
 getch();
}
 1

Asterisk #2

#include<stdio.h>
#include<conio.h>
void main()
{
 int i, j, k, row;
 clrscr();
 printf("Enter the number of rows you want:\n");
 scanf("%d",&row);
 for(i=row;i>=1;i--)
 {
  for(j=1;j<i;j++) {="" printf("="" ");="" }="" for(k="row;k">=i;k--)
  {
   printf("*");
  }
  printf("\n");
 }
 getch();
}
 2

Asterisk #3

#include<stdio.h>
#include<conio.h>
void main()
{
 int row,i,j;
 clrscr();
 printf("Enter the number of rows you want: \n");
 scanf("%d",&row);
 for(i=row;i>=1;i--)
 {
  for(j=1;j<=i;j++)
  {
   printf("* ");
  }
  printf("\n");
 }
 getch();
}
 3