/* add.c
* a simple C program
*/
#include <stdio.h>
#define LAST 10
int main()
{
int i, sum = 0;
for ( i = 1; i <= LAST; i++ ) {
sum += i;
} /*-for-*/
printf("sum = %d\n", sum);
return 0;
}
The main parts are:
# character and the
lack of semicolons)
Here's a brief description of those parts:
/* and continue, ignoring
newlines, until the next */. Notice that this means there is
no nesting of comments. We adhere to ANSI-C standard (until C99
becomes more ubiquitous), so you cannot assume that //
comments until the end of a line will work. It may turn out that
some compilers accept these, but you cannot assume that all
compilers (particularly the one used by the marking TA) will.
#include <stdio.h>
#define BEGIN {
#define END }
int main()
BEGIN
printf("Hello World!\n");
return 0;
END