hi, please go threw output and code.
solution.
#include <stdio.h>
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];
if(out > 0) // put here condition so that it will not became devide by 0
tot = tot + 0xffffffff/out;
cnt++;
}
printf("\n Total = [%d]\n",tot);
return 0;
}
- problem is at line 9 : tot = tot + 0xffffffff/out; and at line 5.int val[] = {5,54,76,91,35,27,45,15,99,0};
last elemenet of val is 0. so when out is geting 0 then it became devide by zero.
so it will give segmentation fault and will recive signal.
- signal is SIGFPE, Arithmetic exception.
- we can fix by putting if condition before deviding.we make sure it should be positive value.
Question! Problem 1.c Problem 2.c Problem 3.c .Use make -f Makefile to compile the three problem...