Here is a straightforward program to sum the integers from 1 to 10.
Of course, if you really needed this sum you would likely use the familiar formula. But lets forget that for now.
/* --- sumVersion1.c --- */ #include <stdio.h> void main() { const int N = 10; int sum = 0; int j; for ( j=1; j<=N; j++ ) sum += j; printf( "sum: %d\n", sum ); }
All variables and the constant have block scope for the body of main()
.
Question: What does the project write?
Is there anything wrong with the program?