C Program That Reads A Non-Negative Integer and Computes Its Factorial

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

C program that reads a non-negative

integer and computes its factorial


Search enhanced by Google

More Categories.. Go
Bca & Mca Mba/Bba/Bms CIC CBSE More Ebooks Forum Management
Library Free Magazines Contact Us

Path :: Home :: Bca & Mca :: Mca Assignments Help :: 2008 :: MCS-11 Free Answers

Q. a) Write a C program that reads a non-negative integer and computes Related Links
and prints its factorial. Final Projects
Ignou Courses
Ebooks/Articles
Answer submitted by a student Bca Question Papers
Mca Question Papers
Bca/Mca Assignments
Free IT Magazines

Featured Management
Resources (FREE)
Systems, Loss Prevention, Human
Resources, Online Retailing,
Communications, Marketing,
Merchandising, and Other Vital Store
Operations.
As stated in the question, the factorial of non-negative
integer n is written n! and is defined as - Flexible Brand Solutions This digital
supplement includes helpful links and
n! = n * (n – 1) * (n – 2) . . . 1 (for values of n greater articles on Sustainable Packaging, as
than or equal to 1) and n! = 1 (for n = 0). well as the new Global Flexible
Packaging Gallery.
For example, consider n = 5, the n! = (5*4*3*2*1) =
120. Telecommunications Magazine
provides objective and informative
The following algorithm illustrates the computation of analysis of operator and carrier
strategies across the globe. Articles
View More....
factorial of a non-negative integer 'n' -
START
Step 1: Read 'n'
Free Industry Resources
Step 2: If n < 0 then let f = 0 else let f = 1
Step 3: Let i = n
ERP vs OMS Comparison
Chart: Download the Step 4: Repeat Step 4 to Step 6 for i >= 1
comparison chart to learn best
practices for... Request Free!
Step 5: f = f * i
Best Enterprise Asset Step 6: i = i - 1
Management (EAM)
Software--Top 5 Picks 2023:
Step 7: Print Factorial :- 'f'
Get an expert... Request Free!

Insider Threats: When the STOP


Attacker Has Valid
Credentials: Combat hard-to-
find, costly... Request Free!

IDC Spotlight Paper:


Transforming Data Security
and Collaboration with
Searchable Encryption:
Request Free!

The Ultimate Guide to


insider Threats: Learn how to
improve your organization’s...
Request Free!

Winter Sales

Book now

/****************** Code starts here ****************/


#include<stdio.h>
#include<conio.h>
void main()
{
int n,i;
long f;
clrscr();
printf("Enter an integer: ");
scanf("%d",&n);
f=n<0?0:1;
for(i=n;i>=1;i--)
f*=i;
printf("Factorial = %ld",f);
}
/****************** Code ends here ****************/
OUTPUT :
Enter an integer: 5
Factorial = 120
Download source code here

<< Previous Answer Next Answer >>

Take Pregnancy Test Online


Ad Pregnancy Map

You might also like