/* Reads a positive number N. Then read N integers and
* print them out together with their sum.
* Author: maSnun (masnun@gmail.com)
*/
#include <stdio.h>
int main(void) {
int n; /* The number of numbers to be read */
int sum; /* The sum of numbers already read */
int current; /* The number just read */
int lcv; /* Loop control variable, it counts the number
of numbers already read */
printf(“How many numbers to add ? (N) > “);
scanf(“%d”,&n); /* We should check that n is really positive*/
sum = 0;
for (lcv=0; lcv < n; lcv++) {
printf(“nEnter an integer > “);
scanf(“%d”,¤t);
/* printf(“nThe number was %dn”, current); */
sum = sum + current;
}
printf(“The sum is %dn”, sum);
return 0;
}
Well, another typical program in C. I don’t think it would need more details. There’s already enough inline comments J