4 Replies - 2741 Views - Last Post: 11 September 2007 - 12:17 PM Rate Topic: -----

#1 Daikide  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 20-August 07

Formula into C code...

Post icon  Posted 10 September 2007 - 10:53 AM

I need to put this formula : http://mathworld.wol...n/equation1.gif

into a C code... don't really know anything about programming... can anyone please help?
Is This A Good Question/Topic? 0
  • +

Replies To: Formula into C code...

#2 MorphiusFaydal  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 43
  • View blog
  • Posts: 1,376
  • Joined: 12-May 05

Re: Formula into C code...

Posted 10 September 2007 - 11:18 AM

http://www.le.ac.uk/cc/tutorials/c/

Should get you started.
Was This Post Helpful? 0
  • +
  • -

#3 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Formula into C code...

Posted 10 September 2007 - 12:49 PM

There is not a lot to. First off, you run though using a for-loop to calculate the average. Once you have the average you can then run though to sum up deviations. Then divide that sum by the number of samples.

pseudo-code for the first part:
  data[] = {10, 23, 43, 34, 15, 24, 28, 13};
  sum1=0;
  for (x=0; x < 8; x++)
  {
	 sum1 += data[x];
  }
  average = sum1/8;



The next part is basically the same thing.
Was This Post Helpful? 0
  • +
  • -

#4 Daikide  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 20-August 07

Re: Formula into C code...

Posted 11 September 2007 - 02:05 AM

View PostNickDMax, on 10 Sep, 2007 - 12:49 PM, said:

There is not a lot to. First off, you run though using a for-loop to calculate the average. Once you have the average you can then run though to sum up deviations. Then divide that sum by the number of samples.

pseudo-code for the first part:
  data[] = {10, 23, 43, 34, 15, 24, 28, 13};
  sum1=0;
  for (x=0; x < 8; x++)
  {
	 sum1 += data[x];
  }
  average = sum1/8;



The next part is basically the same thing.



Thanks man, you really helped me! :^: :P

I don't need it for school or homework thingy... (we don't have a computing class at school :( )

LOL I actually nearly did it but I was too dum to finish it off by myself so I had it like this...


LOL DOn'T CRITESIZE, I JUST STARTED PROGRAMMING LOL: (IT'S BUGGY AS HELL)


main ()
{
} // <------------------- DELETE THIS TOO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

// TS2 - final timestamp
//TS1 - starting timestamp

//<-------DELETE THIS TO START EDITING !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


string s;
file f; ///////
//int ts; //?
dyn_float A; ///////////
int sum;


fopen("")// Have to read in help. parameters here

while (1)
{
fgets (f, s);

while (feof(f)==0) ////////////



fscanf (s, "%d.%d.%d %d:%d:%d %f %f", year, month, day, hour, min, sec, setting, value);

ts = makeTime ( year, month, day, hour);

if (TS1 <ts < TS2) { // if (ts < ts_start) ...

dynAppend (A), value;
DebugN(A);

fclose(f); /////////////
break;
}


int N = 0;
x = value;

//sum =

//sum_2 =


sum = 0;

for (int i = 1; i <= dynlen (A);
i++)

{
sum += A[i];

}



sum = sum + x;
sum_2 = sum_2 + x*x;


int N = 0;

N = N + 1;

Mean = sum/N;

TV.text (Mean);



//Mean - Deviation

//the sum of "x"es /N i.e. x/N


///// dyn_array
////// fprint


///
if ((TS2 > TS1) || (TS2 = TS1)) { // Time Stamp Comparsion TEMP!

TV.text (" Wrong TS input");

Button.enabled = TRUE;

return 0;
}



////

// } // I need this here!

This post has been edited by Daikide: 11 September 2007 - 02:17 AM

Was This Post Helpful? 0
  • +
  • -

#5 MorphiusFaydal  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 43
  • View blog
  • Posts: 1,376
  • Joined: 12-May 05

Re: Formula into C code...

Posted 11 September 2007 - 12:17 PM

When you're posting Code, put them in [ code][ /code] blocks... Without the space after the opening bracket. It's the little #-sign on the toolbar when you're making a post.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1