Mega Code Archive

 
Categories / C Tutorial / Statement
 

For loop backward

#include <stdio.h> int main(void) {   long sum = 0L;   int count = 10;   int i;   for (i = count ; i >= 1 ; sum += i-- );   printf("\nTotal of the first %d numbers is %ld\n", count, sum);   return 0; } Total of the first 10 numbers is 55