Hello.
I want to learn how to indent and format properly my source codes. I have found this online:
https://en.wikipedia.org/wiki/Indent_style
GNU Coding Standards: Formatting
Here is a source code that I wrote where I was criticized that it is not correctly formated:
why this code is not working? i wanted to multiply a matrix by itself
Code:
#include <stdio.h>
int main()
{
int i,j;
int array1[3][3]= {{0,0,0},{0,12,36},{0,32,56}} ;
int sqr[3][3];
/* multiplication part */
for(i=0;i<3;i++)
{
for(j=0;j<3;j++){
sqr[i][j]=array1[i][0]*array1[0][j]+array1[i][1]*array1[1][j]+array1[i][2]*array1[2][j];
}
}
/* here is the printing part */
for(i=0;i<3;i++)
{
for(j=0;j<3;j++){
printf("%d\t",sqr[i][j]);
}
printf("\n");
}
return 0;
}
1) What does it mean to properly indent a code? >> I think that this is pretty clearly explained in the wikipedia article and I think that I already do that right, even in the example
2) What does it mean to properly indent a code? >> Does it mean two empty lines between code? What more?
Thank you.
A corrected version:
Code:
#include <stdio.h>
int main()
{
int i,j;
int array1[3][3]= {{0,0,0},{0,12,36},{0,32,56}} ;
int sqr[3][3];
/* multiplication part */
for(i=0;i<3;i++)
{
for(j=0;j<3;j++){
sqr[i][j]=array1[i][0]*array1[0][j]+array1[i][1]*array1[1][j]+array1[i][2]*array1[2][j];
}
}
/* here is the printing part */
for(i=0;i<3;i++)
{
for(j=0;j<3;j++){
printf("%d\t",sqr[i][j]);
}
printf("\n");
}
return 0;
}