Warning: Declaration of action_plugin_changes::register($controller) should be compatible with DokuWiki_Action_Plugin::register(Doku_Event_Handler $controller) in /volume1/web/dokuwiki/lib/plugins/changes/action.php on line 0 Warning: Declaration of syntax_plugin_code::handle($aMatch, $aState, $aPos, &$aHandler) should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in /volume1/web/dokuwiki/lib/plugins/code/syntax.php on line 42 Warning: Declaration of syntax_plugin_code::render($aFormat, &$aRenderer, &$aData) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in /volume1/web/dokuwiki/lib/plugins/code/syntax.php on line 42 c_prime [Protocol Engineering Lab.]

User Tools

Site Tools


c_prime
/* prime.c: prints out all the prime numbers less than 100 */
#include <stdio.h>
 
#define N 1000
 
void main(void) {
    int i, j, a[N + 1];
 
    for(a[1] = 0, i = 2; i <= N; i++)
        a[i] = 1;
 
    for(i = 2; i <= N/2; i++)
        for(j = 2; j <= N/i; j++)
            a[i * j] = 0;
 
    for(i = 1; i <= N; i++)
        if(a[i])
            printf("%4d", i);
 
    printf("\n");
}
c_prime.txt · Last modified: 2015/02/08 22:03 by jonghyouk