C programming - floating point exception

后端 未结 5 421
生来不讨喜
生来不讨喜 2021-01-03 06:14
matthewmpp@annrogers:~/Programming/C.progs/Personal$ cat prime4.c
/*
 * File:   main.c
 * Author: matthewmpp
 *
 * Created on November 7, 2010, 2:16 PM
 */

#include         


        
5条回答
  •  隐瞒了意图╮
    2021-01-03 06:37

    What happens is a division by zero. You only initialise the first three entries of primes_pf, but iterate over all of them (actually, your loop runs even one past the last entry; use i < 100 instead of i <= 100 to fix this). For all but the first three entries, you divide by some unitialised quantity, and one of the entries apparently happens to be zero. Don't use unitialised values.

提交回复
热议问题