what does \n and %d mean?
Here, in C programming \n is an escape character that helps to create a new line whereas %d is a format specifier that allows to specify only Integer values.
WAP to input any number and display its factorial.
The following is the source code to input any number and display its factorial:
#include <stdio.h>
#include <conio.h>
int main()
{
int a, i, factorial;
factorial = 1;
printf("Input any number: ");
scanf("%d", &a);
if (a==0 || a==1) {
printf("The factorial is 1");
} else if (a<0) {
for (i=a; i<0; ++i) {
factorial *= i;
}
} else {
for (i=a; i>0; --i) {
factorial *= i;
}
}
printf("The factorial of %d is %d.", a, factorial);
}