Calculate Factorial of the integer – C program – Code

Logic for finding Factorial

Let n=5 be the number then,

Factorial = 5 x 4 x 3 x 2 x 1 = 120

So, let’s do same logic in coding

Flowchart

 

Calculate factorial of integer - Flowchart

Calculate factorial of integer – Flowchart

Code

/*find factorial of integer*/

#include<conio.h>

#include<stdio.h>

void main()

{

int n, i, f;

printf(“Enter any number: ”);

scanf(“%d”, &n);

f=1;

for (i = 1; i<=n; i++)

{

f = f * i;

}

printf(“Factorial Value = %d”, f);

getch();

}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>