⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fact.cpp

📁 some useful programs and simple yet
💻 CPP
字号:
#include <stdio.h>
#include <conio.h>
/* A program to calculate the Factorial for a given number.
		     By Morteza Zafari                     */
long int fact(int);
void main()
	{
	int num;
	clrscr();
	printf(".:::: this program will calculate the Factorial for a given number ::::.");
	printf("\n\n  Please input a number to calculate the Factorial: ");
	scanf("%d",&num);
	if (num<0 ) printf("\n  Negative numbers don't have Factorial");
	else printf("\n  The Factorial for %d is %ld\n",num,fact(num));
	getch();
	}

long int fact (int n)
	{
	if (n!=0 && n!=1) return(n*fact(n-1));
	else return(1);
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -