/*-------------------------------------------------------------------*/ /* sumsub.c */ /*-------------------------------------------------------------------*/ #include int sumBetween(int iStart, int iEnd) /* Return the sum of all integers between iStart and iEnd. */ { int i; int iSum = 0; for (i = iStart; i <= iEnd; ++i) iSum += i; return iSum; } /*-------------------------------------------------------------------*/ int main(int argc, char *argv[]) /* Read two integers from stdin, and write to stdout the sum of all integers between the two. */ { int iFirst; int iSecond; int iSumBetween; printf("Enter an integer: "); scanf("%d", &iFirst); printf("Enter another integer that is greater than the first: "); scanf("%d", &iSecond); iSumBetween = sumBetween(iFirst, iSecond); printf("The sum of all integers between the two is %d.\n", iSumBetween); return 0; }