Question: How do I check for a null operator to stop the floating point exception when trying to divide by the last number of the array(0)?
How do I check for a null operator to stop the floating point exception when trying to divide by the last number of the array(0)?
#include
int main() { int out = 0, tot = 0, cnt = 0; int val[] = {5, 54, 76, 91, 35, 27, 45, 15, 99, 0};
while(cnt < 10) { out = val[cnt]; tot = tot + 0xffffffff/out; cnt++; }
printf(" Total = [%d] ", tot); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
