Colora
Oct 29th, 2000, 10:11 AM
Okay this is due tomorrow, I've spent more time on it than any of my other assignments in C++ and VB classes combined and I'm at my wit's end.
Assignment:
Write a program that estimates the value of the mathematical constant "e" by using the formula:
e = 1 + 1/1! + 1/2! + 1/3! + ...
I'm using VC++ 6.0 that came with the book, it's a demo student addition with no help files.
I have notes from class, and don't understand them which is a really bad thing if I'm going to ever actually BE a coder some day. But the notes aren't helping - here's what they say:
#include <iostream.h>
#include <iomanip.h>
float EEE = 1, Factorial = 1;
for (int i = 1; i < 6; i++);
EEE += 1/(Factorial *= i);
cout<<iosflags(ios::fixed | ios:showpoint)<<setprecision (10);
cout<<"e = "<<EEE<<endl;
Now obviously there are problems with my notes which I copied exactly from the chalkboard. There's no main(), and if any of the above are supposed to be functions there's no mention of that either.
I've tried moving things around, placing the lines in and out of a main() routine, and get error after error after error.
I tried adding #include <cmath.h>, said it was an invalid library. I tried #include <cmath> and didn't get that error but got a whole bunch of others.
iosflags is not declared. ios::fixed is illegal. I don't even know what iosflags IS, so obviously I don't know how to declare it. The teacher isn't much help, and as I said there's no help file in the program, and "iosflags" doesn't appear anywhere in the book's index or glossary.
If someone can please help me - even if it means someone else writing the program for me - BUT explaining each line so I can understand it! I'd really appreciate it.
Thanks,
the painfully frustrated Colora
Assignment:
Write a program that estimates the value of the mathematical constant "e" by using the formula:
e = 1 + 1/1! + 1/2! + 1/3! + ...
I'm using VC++ 6.0 that came with the book, it's a demo student addition with no help files.
I have notes from class, and don't understand them which is a really bad thing if I'm going to ever actually BE a coder some day. But the notes aren't helping - here's what they say:
#include <iostream.h>
#include <iomanip.h>
float EEE = 1, Factorial = 1;
for (int i = 1; i < 6; i++);
EEE += 1/(Factorial *= i);
cout<<iosflags(ios::fixed | ios:showpoint)<<setprecision (10);
cout<<"e = "<<EEE<<endl;
Now obviously there are problems with my notes which I copied exactly from the chalkboard. There's no main(), and if any of the above are supposed to be functions there's no mention of that either.
I've tried moving things around, placing the lines in and out of a main() routine, and get error after error after error.
I tried adding #include <cmath.h>, said it was an invalid library. I tried #include <cmath> and didn't get that error but got a whole bunch of others.
iosflags is not declared. ios::fixed is illegal. I don't even know what iosflags IS, so obviously I don't know how to declare it. The teacher isn't much help, and as I said there's no help file in the program, and "iosflags" doesn't appear anywhere in the book's index or glossary.
If someone can please help me - even if it means someone else writing the program for me - BUT explaining each line so I can understand it! I'd really appreciate it.
Thanks,
the painfully frustrated Colora