473,382 Members | 1,258 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Home work assignment

5
hello evrybodyyyyyyyyyyyyyy

i hope someone can help me with this , i have no idea how to start , this kind of problem is new for me help me pls pls pls pls



1. The value ex can be approximated by the sum
1 + x + x2/2! + x3/3! + … + xn/n!
Write a program that takes a value x as input and outputs this sum for n taken
to be each of the values 1 to 100. The program should also output ex
calculated using the predefined function exp. The function exp is a predefined
function such that exp(x) returns an approximation to the value ex. The
function exp is in the library with the header file cmath. Your program should
repeat the calculation for new values of x until the user says she or he is
through.
Use variable of type double to store the factorials or you are likely to produce
integer overflow (or arrange your calculation to avoid any direct calculation of
factorials). 100 lines of output might not fit comfortably on your screen. Output
the 100 output values in a format that will fit all 100 values on the screen. For
example, you might output 10 lines with 10 values on each line.
Mar 3 '07 #1
3 3075
[QUOTE
1. The value ex can be approximated by the sum
1 + x + x2/2! + x3/3! + … + xn/n!
Write a program that takes a value x as input and outputs this sum for n taken
to be each of the values 1 to 100. The program should also output ex
calculated using the predefined function exp. The function exp is a predefined
function such that exp(x) returns an approximation to the value ex. The
function exp is in the library with the header file cmath. Your program should
repeat the calculation for new values of x until the user says she or he is
through.
Use variable of type double to store the factorials or you are likely to produce
integer overflow (or arrange your calculation to avoid any direct calculation of
factorials). 100 lines of output might not fit comfortably on your screen. Output
the 100 output values in a format that will fit all 100 values on the screen. For
example, you might output 10 lines with 10 values on each line.[/quote]
Well, I'm not going to write the thing for you, but I can give you a few tips:

1. Write a function to determine the factorial in each case:

Expand|Select|Wrap|Line Numbers
  1. int factorial(int n)
  2. {
  3.      if(n != 0)
  4.        return n*factorial(n-1);
  5.     else return 1;
  6.  
  7. }
  8.  
2. Write a function to define the given function.

3. Write a function to put the two together

I'm not here to do your homework for you so go on, the factorial function is a recursive function which should help you alot
Mar 4 '07 #2
lonely
5
Well, I'm not going to write the thing for you, but I can give you a few tips:

1. Write a function to determine the factorial in each case:

Expand|Select|Wrap|Line Numbers
  1. int factorial(int n)
  2. {
  3.      if(n != 0)
  4.        return n*factorial(n-1);
  5.     else return 1;
  6.  
  7. }
  8.  
2. Write a function to define the given function.

3. Write a function to put the two together

I'm not here to do your homework for you so go on, the factorial function is a recursive function which should help you alot


man i diden't ask to do my homework i just ask for help how to start that's all

and im glad u did thank u very much
Mar 4 '07 #3
man i diden't ask to do my homework i just ask for help how to start that's all

and im glad u did thank u very much
Sorry, I sounded a bit harsh, didn't mean it like that

Well for any more help, just shout ... not in the literal way of course ;-)
Mar 4 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: sunfox | last post by:
Please help!! I have a difficulty in writing an assignment which is related to Visual C++ V6.0. Can anybody here assist me to write a program which is able to run under DOS? The program will be...
4
by: PengYu.UT | last post by:
The following shows the source code and the error message(from g++-3.3). I wrote two assignment operator. One is for the same type case, the other one is for different type case. I'm wondering why...
18
by: Daniel Billingsley | last post by:
Or seem to anyway. ===== string abc; if ((abc=getString()) != "") { MessageBox.Show(abc); } private string getString() {
4
by: Nate Hekman | last post by:
I can understand that one wouldn't be able to run a full-fledged web server from XP Home, but is there not a toned-down version of IIS/ASP.NET a developer can use on XP Home? I just bought a new...
4
by: thinktwice | last post by:
template <class T> class CThrowable { protected: virtual void Assign(T val) { m_val = val; if (IsBad()) { throw val;
6
by: Paul Lautman | last post by:
Normally I ask why things DON'T work!! However, according to what I have read at http://subsimple.com/bookmarklets/rules.asp the bookmarklet: javascript:q = prompt("Enter destination or leave...
6
by: Arun Nair | last post by:
import string class Card: # Not sure if I need to set these first??? # suitList = () # rankList = () def __init__(self,suit,rank): self.suit = suit
8
by: heng | last post by:
I define my own assignment operator, but it doesn't work as I imagined. #include<iostream> #include <string> using namespace std; class A{ int x; public: int y;
12
by: suprdad25 | last post by:
I was given an assignment to create a MS Access home inventory database that has a minimum of 5 tables. I have 7 tables (Appliances,Vehicles,Movies,Furniture,Games,Electronics, and Rooms) The...
2
chunk1978
by: chunk1978 | last post by:
i wrote a custom PHP script last year and everything worked perfectly... recently my webserver upgraded to PHP 5 and now my script doesn't work properly. what the script does is: users fill out...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.