#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[]) { int i, n, fac; i = 1; fac = 1; printf("enter any number:\n"); scanf_s("%d", &n); for (i = 1; i < n; i++) { fac = fac*i; } printf("factorial of %d is %d", n, fac); getchar(); }
output screen:
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[]) { int i, n, fac; i = 1; fac = 1; printf("enter any number:\n"); scanf_s("%d", &n); for (i = 1; i < n; i++) { fac = fac*i; } printf("factorial of %d is %d", n, fac); getchar(); }
output screen: