Home Forums C Programming C program that estimates the value of the math constant e

Viewing 1 reply thread
  • Author
    Posts
    • #2169
      SilviaJamieson
      Participant

      Hi everyone, wonder if anyone can point me in the right direction for this problem I have looked at tutorials but I don’t understand why some have #include while others have #include and also I have never seen cin>> and <

      Write a C program that estimates the value of the mathematical constant e by using the
      following formula.

      e= 1 + 1/(1!) + 1/(2!) + 1/(3!) +…1/(n!)

      – The program should ask user to input the number of terms (n) to approximate value of e
      – Then it calculates and displays the approximated value of constant e
      – Compare the approximated value of e with the given mathematical constant
      e = 2.7182818284590… and find the absolute [use fabs()] difference between the two

      An example of input/output dialog is shown below:-

      Enter number of terms (n) : 15
      The approximated value of e : 2.718281828458
      The given mathematical constant e = 2.718281828459
      The absolute difference between the two value : 0.000000000001

      Thanking you in advance, daisy……

    • #3500
      GWILouisaxwzkla
      Participant

      cout and cin are input and output members of a stream object in the file iostream.h . This header file is associated with c++ programs and the method that most c++ programmers use for input and output. cout stands for “console output” and cin stands for console input. You can use them more easily than printf and scanf :

      for the program , try:

Viewing 1 reply thread
  • The forum ‘C Programming’ is closed to new topics and replies.