The factorial of a nonnegative integer n is written n!
(pronounced “n factorial”) and is defined as
follows:
n! = n · (n - 1) · (n - 2) · … · 1 (for values of n greater
than to 1)
and
n! = 1 (for n = 0 or n = 1).
For example, 5! = 5 · 4 · 3 · 2 · 1, which is 120. Use while
structures in each of the following:
a) Write a program that reads a nonnegative integer and
computes and prints its factorial. Use the
following function prototype to calculate factorial:
int myFactorial(int n);
b) Write a program that estimates the value of the
mathematical constant e by using the formula:
Use the following function prototype to calculate e:
double myE( );
Hint: Use an accuracy of 10 terms.
c) Write a program that computes the value of ex by using
the formula
Use the following function prototype to calculate e:
double myEx(int x);

Answers were Sorted based on User's Feedback



The factorial of a nonnegative integer n is written n! (pronounced “n factorial”) and is define..

Answer / amal

#include<iostream>
using namespace std;
int main()
{
int x, factorial = 1;
cout << "Enter integer: ";
cin >> x;
if (x > 0)
{
while (x > 0)
{
factorial *= x;
x--; }
}
cout << "Factorial: " << factorial<<endl;
system("PAUSE");
return 0;
}

Is This Answer Correct ?    21 Yes 13 No

The factorial of a nonnegative integer n is written n! (pronounced “n factorial”) and is define..

Answer / wew

The factorial of a nonnegative integer n is written n!
(pronounced &#65533;n factorial&#65533;) and is defined as
follows:
n! = n · (n - 1) · (n - 2) · &#65533; · 1 (for values of n greater
than to 1)
and
n! = 1 (for n = 0 or n = 1).
For example, 5! = 5 · 4 · 3 · 2 · 1, which is 120. Use while
structures in each of the following:
a) Write a program that reads a nonnegative integer and
computes and prints its factorial. Use the
following function prototype to calculate factorial:
int myFactorial(int n);
b) Write a program that estimates the value of the
mathematical constant e by using the formula:
Use the following function prototype to calculate e:
double myE( );
Hint: Use an accuracy of 10 terms.
c) Write a program that computes the value of ex by using
the formula
Use the following function prototype to calculate e:
double myEx(int x);

Is This Answer Correct ?    14 Yes 16 No

Post New Answer

More Engineering AllOther Interview Questions

if we give you the job AS A PETROLEUM ENGINEER WHAT WILL YOU DO(that is extraordinary) for our company

0 Answers   ONGC,


how to connect oracle with java ? Give detail explanation.

0 Answers   Bata,


Hi I want to know how API gravity has been come up with in Oil Industry, especially figures in the following formula: API=(141.5/SG)-131.5

0 Answers  


Please state briefly the reasons why you think you are an outstanding candidate for this job

0 Answers  


If memory is allocated to a class,when object of the class is created then how do we use the abstract class methods.coz v cant create obj of abstract class, only reference is created,when the abstract class data and members got the space in memory??

0 Answers  






Tell me all about production of drought and its losses In the boiler?

0 Answers   Dairy Science College,


Explain diffrent parts of an instruction format.

0 Answers  


what is the definition(body) of a default constructor in c++?

0 Answers  


Do you have any tips for using 3G phones?

0 Answers  


how to delete four out of five duplicate records in a table using sql

0 Answers  


which of the following is not a storage class specifier in c?

1 Answers   Infosys,


find the net id and host id of the following IPV4 117.34.3.8 and 132.57.8.6

0 Answers   Green University of Bangladesh,


Categories
  • Civil Engineering Interview Questions Civil Engineering (5085)
  • Mechanical Engineering Interview Questions Mechanical Engineering (4452)
  • Electrical Engineering Interview Questions Electrical Engineering (16638)
  • Electronics Communications Interview Questions Electronics Communications (3918)
  • Chemical Engineering Interview Questions Chemical Engineering (1095)
  • Aeronautical Engineering Interview Questions Aeronautical Engineering (239)
  • Bio Engineering Interview Questions Bio Engineering (96)
  • Metallurgy Interview Questions Metallurgy (361)
  • Industrial Engineering Interview Questions Industrial Engineering (259)
  • Instrumentation Interview Questions Instrumentation (3014)
  • Automobile Engineering Interview Questions Automobile Engineering (332)
  • Mechatronics Engineering Interview Questions Mechatronics Engineering (97)
  • Marine Engineering Interview Questions Marine Engineering (124)
  • Power Plant Engineering Interview Questions Power Plant Engineering (172)
  • Textile Engineering Interview Questions Textile Engineering (575)
  • Production Engineering Interview Questions Production Engineering (25)
  • Satellite Systems Engineering Interview Questions Satellite Systems Engineering (106)
  • Engineering AllOther Interview Questions Engineering AllOther (1379)