16/11/2022 ; 5:28 PM
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
# include <stdio.h>
|
||||
/* Factorial.
|
||||
El programa calcula el factorial de un número entero.
|
||||
|
||||
FAC, I, NUM: variables de tipo entero. */
|
||||
void main(void)
|
||||
{
|
||||
int I, NUM;
|
||||
long FAC;
|
||||
printf("\nIngrese el numero: ");
|
||||
scanf("%i", &NUM);
|
||||
if (NUM >= 0)
|
||||
{
|
||||
FAC = 1;
|
||||
|
||||
for (I = 1; I <= NUM; I++)
|
||||
|
||||
FAC *= I;
|
||||
printf("\El factorial de %i es: %ld", NUM, FAC);
|
||||
}
|
||||
else
|
||||
printf("\nError en el dato ingresado");
|
||||
}
|
||||
Reference in New Issue
Block a user