4.main(){ int i,j; long int f=1; for (i=1, i< 10; i++) f=f*i; } prinf(“%ld",f);}

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section: Chapter Questions
Problem 4PP: (Numerical) Write and test a function that returns the position of the largest and smallest values...
icon
Related questions
Question

Comment each C statement in C program and write output .

4.main(){
int i.j;
long int f=1;
for (i=1, i< 10; i++)
f=f*i;
prinf(“%ld",f);}
Transcribed Image Text:4.main(){ int i.j; long int f=1; for (i=1, i< 10; i++) f=f*i; prinf(“%ld",f);}
Expert Solution
Step 1
Factorial Program in C: Factorial of n is the product of all positive descending integers. 
Factorial of n is denoted by n!

Here, 5! is pronounced as "5 factorial", it is also called "5 bang" or "5 shriek".

The factorial is normally used in Combinations and Permutations (mathematics).

There are many ways to write the factorial program in c language. Let's see the 2 ways to write the factorial program.

  • Factorial Program using loop
  • Factorial Program using recursion
  •  

This program takes a positive integer from the user and computes the factorial using for loop.

 

 
 

Since the factorial of a number may be very large, the type of factorial variable is declared as unsigned long long.

If the user enters a negative number, the program displays a custom error message.


steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Structure chart
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning