I am studying C while listening to a lecture by myself. When I was studying coding and listening to a lecture, I heard that writing code should be concise and maintainable. But I didn't know if I was doing well, so I felt the need for feedback. But it's hard to find anyone who can give us feedback, and I don't know where to ask.
I am Korean and I am using a translator because I am not good at English. Please understand if the context feels a little strange
For example How do you make this code simpler and more intuitive?
Output
* ** *** **** ***** **** *** ** *
Program:
#include<stdio.h>
int main(void)
{
int i, j;
int n = 5;
for (i = 1; i <= n; ++i)
{
for (j = 1; j <= i; ++j)
putchar('*');
putchar('\n');
}
for (i = n - 1; i >= 1; --i)
{
for (j = 1; j <= i; ++j)
putchar('*');
putchar('\n');
}
return 0;
}
Would it be better to write if? Would it be better to have a variable name other than n?