It is a signal representing core dumped means if you do any invalid operation the you will get “SIGFPE”
error. In case floating point error means division by 0 cause this error so please check your code and make sure that you are not operating this type of operation means make sure that you are not dividing by 0
#include<stdio.h>
main()
{
long int a,b,c,d,e,j,I,n;
scanf("%ld",&a);
for(I=0;I<a;I++)
{
scanf("%ld%ld",&b,&c);
e=bc;
for(j=e;j>1;j–)
{
n=jj;
if(e%n==0)
{
d=e/n;
printf("%ld",d);
break;
}
}
}
}I am getting sigfpe.Where is the problem in my code .Can any one to it???
#include
using namespace std;
int main()
{
long long int n;
cin>>n;
long long int a[n+1],mul[n+1]={1};
mul[0]=1;
for(long long int i=1;i<=n;i++)
{
cin>>a[i];
mul[i]=1;
}
for(long long int i=1;i<=n;i++)
{
mul[i]=mul[i-1]*a[i];
}
long long int t;
cin>>t;
while(t–)
{
long long int re=1,li,ri,mi;
cin>>li>>ri>>mi;
re=(mul[ri])/(mul[li-1]);
if(re>=mi)
{
re=re%mi;
}
cout<<re<<endl;
}
return 0;
}
iam getting run time error what is the problem
Note:- In C++ if you fail to typecast the variables properly , you may end up facing a SIGFPE . I faced one as I was storing an int value in a vector of long long int !
@ashishpm Bro keep dividing the multiplication as its increasing as it is causing Integer Overflow…you are doing whole multiplication at once which is causing To extend the long long range making it negative.
cin >> n;
for(i=0;i<n;i++)
{
cin >> a[i];
}
if (n>10)
return 0;
while(i<n)
{
rem=a[i++]%a[j++];
if (rem>max)
max=rem;
if (j==n)
j=0;
}
cout<<"the result of the puzzle"<<max;
return 0;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
int t; cin >> t;
while (t--) {
long long l, r, g;
cin >> l >> r >> g;
long long cnt = r / g - (l - 1) / g;
cout << (cnt >= 0 ? cnt : r / g == 1) << "\n";
}
return 0;
}
I got SIGFPE in above code. When I change "\n" to endl, it become ok. But why ?
SIGFPE This is my code. i tried very hard to find out the problem but i am not able to do so …so if anyone can find out the problem in my code it will be really helpful
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t–)
{
int n,r;
cin>>n>>r;
int a[n],b[n];
int i;
for(i=0;i<n;i++)
{
cin>>a[i];
}