1 Replies - 839 Views - Last Post: 27 June 2011 - 12:56 AM Rate Topic: -----

#1 uofmx12  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 10-March 11

'Process terminated with status 0', but code runs with endless

Posted 26 June 2011 - 11:03 PM

What I have is an equation, using floats, that I have a constant 'a' and then a value 'r' that will vary from 2-700pm(10^-12) that I want to plug into the equation an increment it by 4pm and then output the result.

Keep getting this error when building/running my code in codeblocks:
-------------- Build: Debug in ph113cp2 ---------------

Compiling: main.cpp
Linking console executable: bin\Debug\ph113cp2.exe
Output size is 917.69 KB
'Process terminated with status 0 (0 minutes, 2 seconds)
0 errors, 0 warnings'

And this is what displays after the code:
Process terminated with status -1073741510 (1 minutes, 32 seconds)

Not sure how to fix this, and here is my code. My code runs but displays 0's for everything and seems like an endless loop. Not sure what is going on.

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
double a =pow(5.292,-11);

for(int rr=0; rr<=pow(700,-12); rr+=pow(4,-12)) //increment by 4pm or 4*10^-12
{
double r=rr;
double x=(1/(8.0*pow(a,3.0)))*(4.0*pow(r,2.0)*exp(-r/a)+((pow(r,4.0)/pow(a,2.0))*exp(-r/a))-(((4.0*pow(r,3.0))/a)*exp (-r/a)));
            cout << x << endl;
}
return 0;
}



Also, was wondering is there a way I can display my answers in 1/nm? So, answer*10^9?

Is This A Good Question/Topic? 0
  • +

Replies To: 'Process terminated with status 0', but code runs with endless

#2 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 971
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: 'Process terminated with status 0', but code runs with endless

Posted 27 June 2011 - 12:56 AM

You are using integers instead of floating point numbers:

for(int rr=0; rr<=pow(700,-12); rr+=pow(4,-12)) //increment by 4pm or 4*10^-12


should be:
for(double rr=0; rr<=pow(700,-12.0); rr+=pow(4,-12.0)) //increment by 4pm or 4*10^-12




See the doc: pow()
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1