Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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);

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what are db_options used for?

1913


Please tell us about an implementation that you worked on that did not go as planned. What were the challenges you faced and how did you overcome them

1991


Please. Does someone know how to inicialize tapes in ATL? I need have 100 tapes to init inside the ATL, how is the process to complete this request?

2072


I APPLIED SBIPO EXAM PLZ SEND ME THE INTERVIEW QUESTIONS AND GD TOPICS AND WRITTENEXAM QUESTIONS

2123


I am getting the following error,when I am running the script, Cannot identify the specified item of the regions object. Confirm that the specified item is included in the object's item collection. My Script: Itemname=Browser("MLSListings.com").Page ("MLSListings.com").WebList("regions").GetItem(i+1) Print Itemname Browser("MLSListings.com").Page ("MLSListings.com").WebList("regions").Select "Itemname" Any Help? Thanks, Uma

2252


wats the difference between RS latch using NAND n NOR gate? which is to be preffered?

2313


Explain different parts of an instruction. What does the addressing mode bit specifies?

4503


can any one please tell me what is mean by back papers,back log,historical standing ????????? this mean history of arrears is it correct or not.........

2404


WHY IBM MAINFRAME TECHNOLOY IS USED.THOUGH, SINCE ITS INTRODUCTION IT HAS NO MAJOR UPDATATION OR MODIFICATION;BUT STILL IT IS IN DEMAND........WWWWWWWWWWWWWWHHHHHYYYYYYYY????????????

1977


How is the parity flag actually set in the 8085 microprocessor?

2042


Can you connect Active Directory to other 3rd-party Directory Services? Name a few options.

2086


What are special features of Silk Test ? In what way it is advanced than QTP?

2117


operation of carrier aided protection and what is the basis for choice of frequncy in powerline carrier system

6377


what is the difference between composite key and primary key in sap abap

2630


can 25mm thik and 8.5x8.5 size cast iron plate can bear a weight of 250 tons if it can what would be the compostion

1754