I'll give you some pointers to get you started. First of all, the correct form of a C program is:
Code:
int main()
{
/* Code goes here */
return 0;
}
Notice that the main function returns an int. You should return 0 or EXIT_SUCCESS to terminate the program normally.
The next thing you need to look at is your code formatting. Look at the code you posted, and see how ugly it looks. Below I have posted your exact same code. The only thing I have changed, is the main function returning 0, and the formatting.
Code:
#include <stdio.h>
int main ()
{
int line;
int lc;
int a;
printf("Enter an integer between 1 and 9: ");
scanf("%d" , &a);
if(a > 0 && a < 10)
{
for(lc = 1; lc <= a; lc++)
{
for(line = 0; line <= (a - lc); line++)
{
printf(" ");
}
for(line = 1; line >= lc; line++)
{
printf("%d", line);
}
for(line = lc - 1; line >= 1; line--)
{
printf("%d", line);
}
printf("\n");
}
}
else
{
printf("You have entered an invalid number.\n");
}
return 0;
}
See how much easier it is to read? Proper formatting allows people to look at your code, and understand it faster.
My last suggestion to you is to get into the habit of using comments in your code. This not only helps other people that read your code, but it also helps yourself when you come back to code that you wrote a couple months ago.
Read the links that Hammer posted, and then take another look at your code. If you still have questions, come back here and ask away.