How to print pattern with programming language c

Star printing
Star printing : part1

#include <stdio.h>
int main() // main function
{int i,j,c;
printf("Enter value: ");
scanf("%d",&c);
for(i=1; i<=c;i++) //for loop start
{ for(j=0; j<=i-1;j++) // another for loop
printf("*");
printf("\n"); // for new line
}
return 0;
}

 

 

Star printing c progream
Star printing : part2

#include 
int main()
{ int i,j,c,k;
printf("Enter value: ");
scanf("%d",&c);
for(i=1; i<=c;i++){
for(k=i; k<=c-1;k++) //for loop start
printf(" ");
for(j=0; j<=i-1;j++) //for loop start
printf("*");
printf("\n");
}
return 0;
}
Leave a reply