Then there is the most reasonable solution:
Code:
#include <stdio.h>
#define TABLE_SIZE(table) sizeof(table) / sizeof(table[0])
static const int prime_table[] = {
/* Empty element */0,
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41,
43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97,
};
int main ( void )
{
int index;
puts ( "Prime numbers from 2 to 100:" );
for ( index = 1; index < TABLE_SIZE ( prime_table ); index++ )
printf ( "%-3d%c", prime_table[index], ( index % 5 == 0 ) ? '\n' : ' ' );
return 0;
}
-Prelude