
October 29th, 2012, 11:46 PM
|
|
Contributing User
|
|
Join Date: Oct 2012
Posts: 30
Time spent in forums: 11 h 3 m 34 sec
Reputation Power: 1
|
|
|
Floating point exception
Quote: | Originally Posted by lalaman I was wondering if there was a way to insert text into some sort of array like function. Below is a sample of my code. I need to print out "Yes" in case sum is divisble by x and "No" in the opposite case in the order it occurs after all the text is inserted.
Code:
for(i=0;i<n;i++)
{
printf("\n");
scanf("%d", &x);
sum=0;
for(sum=0;x>0;x--)
{
scanf("%d", &c);
sum=sum+c;
}
--------------- X is 0 --------------
if(sum%x==0)
A[i]="YES";
else
A[i]="NO";
}
for(i=0;i<n;i++)
printf("%c", A[i])
|
X will be zero due to decrement operation in the for loop, So it will end up throwing Floating point exception..
|