Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

equations in C++

Name: Anonymous 2009-03-30 19:24

im not very well versed to say the least in expressing mathematical formula in C++ 
y = 1 - t - (t^2)/2 + (t^4/12) + t^5/30 + (t^6)/180
this is the formula i need to express
t(ime) being the user input variable and y being the output
just need some direction. i got to about here :P
#include <iostream>
using namespace std;
main()
{
    int time;
    cout << "Enter value of variable time: \n";
    cin >> time;

Name: Anonymous 2009-03-30 20:32

>>5
#include <limits.h>
#include <stdio.h>

int main(void)
{ long double t, y;
  char time[LINE_MAX];
  fputs("t = ", stdout);
  fflush(stdout);
  fgets(time, LINE_MAX, stdin);
  t = strtold(time, NULL);
  y = 1 + t * (-1 + t * (-1 + t * t * (1 / 2 + t * (1 + t / 6) / 5) / 3) / 2);
  printf("y = %Lg\n", y); }

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List