My C language learning journey

未标题-1.jpg
I want to write a code to print rhombus with use C program language.This code would used six for statements.The previous three for statements be used to print the upper five lines.After three for statements be used to print the following four lines.code as follows:

#include"stdio.h"
int main(void){

int a,b;
for(a=1;a<=5;a++)
{
    for(b=1;b<=5-a;b++)
        printf(" ");
    for(b=1;b<=2*a-1;b++)
        printf("*");
        printf("\n");
}
for(a=1;a<=4;a++)
{
    for(b=1;b<=a;b++)
        printf(" ");
    for(b=2*a-1;b<=7;b++)
        printf("*");
        printf("\n");
}
    return 0;

}

捕获.PNG

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now
Logo
Center