The code given looks OK, but if you want the sum without including the last number, as is generally the case you should change the for loop like this
for(; index < endno; index ++)
More Related Contents:
- “static const” vs “#define” vs “enum”
- What’s the difference between “mod” and “remainder”?
- How does C compute sin() and other math functions?
- Can we change the value of an object defined with const through pointers?
- Can a const variable be used to declare the size of an array in C?
- Rounding integer division (instead of truncating)
- Mapping a numeric range onto another
- Power by squaring for negative exponents
- In C, can a const variable be modified via a pointer?
- Where are constant variables stored in C?
- Variably modified array at file scope
- “undefined reference to `pow'” even with math.h and the library link -lm [duplicate]
- __attribute__((const)) vs __attribute__((pure)) in GNU C
- const usage with pointers in C
- Confusion regarding modification of const variable using pointers
- Are floating point operations in C associative?
- Should useless type qualifiers on return types be used, for clarity?
- Strange warning in a C function const multidimensional-array argument
- Gaussian elimination without result for acceleration
- Deep Analysis of Const Qualifier in C
- signed and unsigned arithmetic implementation on x86
- Is the sizeof(enum) == sizeof(int), always?
- Why does gdb evaluate sqrt(3) to 0?
- C: How to wrap a float to the interval [-pi, pi)
- To the power of in C? [duplicate]
- sin, cos, tan and rounding error
- How does this bitwise operation check for a power of 2?
- Why is the behavior of the modulo operator (%) different between C and Ruby for negative integers?
- Conditional tests in primality by trial division
- A possible algorithm for determining whether two strings are anagrams of one another? [closed]