Attachments
-
You do not have permission to view the full content of this post. Log in or register now.
#include <stdio.h>
int main()
{
int n,o;
unsigned long factorial=1;
printf("Enter an integer: ");
scanf("%d", &n);
o = n;
if (n < 0)
{
printf("Invalid number!");
}
else
{
while (n > 0)
{
factorial = factorial * n;
n = n - 1;
}
printf("\n%d! = %lu", o, factorial);
}
getch();
return 0;
}
#include <stdio.h>
int main()
{
int n,o;
unsigned long factorial=1;
printf("Enter an integer: ");
scanf("%d", &n);
o = n;
if (n < 0)
{
printf("Invalid number!");
}
else
{
while (n > 0)
{
factorial = factorial * n;
n = n - 1;
}
printf("\n%d! = %lu", o, factorial);
}
getch();
return 0;
}