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

which is best car to buy in india, if the budget is below or equal to 3.5 lakhs?

4 Answers   Hyundai,


the ability for the processor to delegate its use by application is called

1 Answers  


i want a program in c# for 100 or for a number greater than 100.....pls help

0 Answers  


why there is a collision in switch

0 Answers  


1.what a diffrenrs v-lan & (layer)l-3,l-2 bitween plz define defination of these? 2.how to configur ms outlook & lotus note (ibm)

0 Answers  






how 2 write a program of this pattern usin for loop?? 1 2 3 4 5 6 7 8 9 10

0 Answers  


if your monitor is not started with your cpu, but start when monitor attach to another cpu then where is the problem?

2 Answers  


When are the SBI clerk 2010 results are expected???

1 Answers  


Define configuration and calibration and explain with an example

0 Answers  


How can I get know that my pc contains dram or sram..?

0 Answers  


a particle moving in a straight line with constant acceleration has a velocity of 8m/s at one instant and 3 seconds later it has a velocity of 2m/s.find its acceleration.

1 Answers  


Can anyone send me iocl written test paper fro computer engineers

0 Answers   IOCL,


Categories
  • Civil Engineering Interview Questions Civil Engineering (5085)
  • Mechanical Engineering Interview Questions Mechanical Engineering (4451)
  • Electrical Engineering Interview Questions Electrical Engineering (16632)
  • 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)