Results 1 to 2 of 2

Thread: C++ help! totally new to this stuff.?

  1. #1
    Join Date
    Nov 2010

    Default C++ help! totally new to this stuff.?

    Write a program that have four different functions, main() in addition to three more user-defined functions. The main() function is the one that will invoke all other functions. Appropriate display messages should be used in main() before and after each invocation to indicate that the function is about to be called and the function did return. Each of these function should be stored on a separate file thus your project will have four different C++ files.

    The first user-defined function is a void one that basically computes the result of the series below and displays it on the screen in a table format as shown also below. All computation and display must be inside the function. The function should repetitively compute the series for values of I from 1 to 20 (as shown in the table). Once done, the function returns to the calling function, main(). Hint: Function prototype can take the form “void ComputeSeries(void)”.
    m(i) = (1/2) + (2/3) + ... + [i/(i+1)]
    i m(i)
    1 0.5
    2 1.1667
    19 16.4023
    20 17.3546

    The second function is a value-returning function that uses reference parameters to pass values to the calling module. This function takes the following form “double ComputeTrigonometricValues(int, double&, double&)”. The first argument is the degree which is passed as integer, the second one is a reference parameter the will contain the value of computing the trigonometric sin function upon that degree, the last argument is the value of computing the trigonometric cosine function upon passed degree. The return value of that function is the tangent (tan value) of the same degree. The mere task of this function is to receive a degree from main() then compute and return back to the caller the values for sin, cos, and tan of that degree. The main() function is in charge of repeatedly calling that function, ComputeTrigonometricValues(), in order to display on the screen the table shown below.
    degree sin cos tan
    0 0.0 1.0 0.0
    10 0.1736 0.9848 0.1763
    350 -.01736 0.9848 -0.1763
    360 0.0 1.0 0.0

    The last function is a value returning function that has the form “double ComputeSquareRoot(double num) and uses passing-by-value to communicate the values in which we need to compute its square root. This function does NOT use the standard sqrt() library function to compute the square root instead it uses the following approximation.
    The square root of a number, num, can be approximated by ‎repeatedly performing a calculation using the following ‎formula:‎
    nextGuess = (lastGuess + (num / lastGuess)) / 2‎
    The initial guess can be any positive value (e.g., 1). This ‎value will be the starting value for lastGuess. If the ‎difference between nextGuess and lastGuess is less than a ‎very small number, such as 0.0001, you can claim that ‎nextGuess is the approximated square root of num. If not, ‎nextGuess becomes the lastGuess and continue the ‎approximation process.‎ Hint: this algoeithm can be implemented with while loop(s)

    Once the function is over, it will return the value of the computed square root to the calling module, main(). Also, main() is in charge of repeatedly calling the function to compute the square root for (0, 10, 20, 30, ….. 100) and put them in tabular format shown below. In addition, main() should display in the third column of that table the value of the computed square root for that given number but now using the sqrt library function found in the cmath header file.
    num sqrt() ComputeSquareRoot
    0 0.0
    100 10.0

    Anyhelp at all would greatly be appreciated! As I am totally new to this, just this semester and this went totally over my head. thank soooo much in advance!

  2. #2
    Join Date
    Dec 2003

    Default Re: C++ help! totally new to this stuff.?


    This forum isn't about C++.

    If you're doing a course, then I recommend you ask your lecturer or tutor for assistance.

    That's what they are paid a salary for.

    Otherwise, I'm sure you can find several forums for helping students with programming issues.

    This is just the wrong place to ask.
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Wierd Stuff Happening HELP!!!
    By wissamyamout in forum Community Support
    Replies: 5
    Last Post: 17-Nov-2010, 09:06 PM
  2. totally lost on error form
    By ds67 in forum Community Support
    Replies: 2
    Last Post: 25-Feb-2008, 09:25 AM
  3. Totally Lost with this FormMail thing...
    By eant842183 in forum FormMail Subscription Support
    Replies: 2
    Last Post: 11-Jul-2005, 09:24 PM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts