Curso de Programación en C/Prog135

De WikiCabal
Ir a la navegación Ir a la búsqueda

Prog135

#include <stdio.h>

#define A_VER
#define LIMIT 4

int main(void)
{
  int i;
  int total = 0;

  for( i = 1; i <= LIMIT; i++ )
  {
    total += 2 * i * i + 1;
#ifdef A_VER
    printf( "i = %d, SubTotal = %d\n", i, total);
#endif
  }
  printf( "Total = %d\n", total );

  return 0;
}

Resultado

[rrc@pwyr CClase]$ gcc -Wall -o Prog135 Prog135.c
[rrc@pwyr CClase]$ ./Prog135
i = 1, SubTotal = 3
i = 2, SubTotal = 12
i = 3, SubTotal = 31
i = 4, SubTotal = 64
Total = 64
[rrc@pwyr CClase]$ 

Explicación