repl.it
@SylvianBryan/

Arrange star and number using loops

C

No description

fork
loading
Files
  • main.c
  • main
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*N01422856 Sylvian Bryan. 2019/04/10. This program pattern numbers follow by stars using various Loops.*/   

#include <stdio.h>
#include <stdlib.h>

int main() 
{
char star='*';
int col=20;
int rows=3;
int row2=2; 
int c=4; 

printf("\n\n\n");
for (int a=1; a<=10;a++)//Prints One 
  {printf(" ");
  }
  for (int a=1; a<=1;a++)
  {printf("%d\n",a);
  }
  for (int a=1; a<=10;a++)
  {printf(" ");
  }
  for (int a=1; a<=1;++a)
  {printf("%c", star);//Prints first Star. 
  printf("\n\n");
  }
  for (int a=2; a<=4;++a)
  {printf(" "); 
do 
 {printf("      ");
  printf ("%d",a++);
  }while (a<=3);
  printf("\n");
  printf ("      "); 
for (int x=1; x<=2;x++)//Prints Stars with loop. 
    printf ("%c", star); 
    printf ("     "); 
for (int b=1; b<=rows;b++)//Prints Stars with loop. 
  printf ("%c", star); 
  printf("\n\n");
  printf (" ");
for(int f=4;f<=6;f++)//Prints 456 with spaces with loop.
printf("%d        ",f);
printf("         ");
printf("\n");
for (int j=1;j<=4;j++) // Loop that prints 4 stars
  printf ("%c", star); 
printf("    ");
for (int j=1;j<=5;j++)// Loop that prints 5 stars
  printf ("%c", star); 
printf("   ");
for (int j=1;j<=6;j++) // Loop that prints 6 stars
  printf ("%c", star); 
  printf("\n\n");

}return 0;
  }