|
|
back to boardRuntime error: Access Violation I'm getting a 'runtime error: access violation' on my code. Please help me out. Here is the program in C++: #include<iostream> using namespace std; int main() { int i,j,a,sum,p,q; float small,ratio[30],x; cin>>p>>q; //Inputs //To find the ratio for each number in the interval i to j. for(i=p;i<=q;i++) {sum=0; for(j=1;j<i;j+=1) { if(i%j==0) { sum+=j; } } ratio[i]=sum/i; } //To find the number with the smallest ratio and display it. small=ratio[p]; for(i=p+1;i<=q;i+=1) { if(ratio[i]<small) { small=ratio[i]; x=i; } } cout<<x; return 0; } |
|
|