Programming Examples

C program to input any number and print its factorial value using goto statement


Write a C program to input any number and print its factorial value using goto statement.

Solution

#include<stdio.h>
int main()
{
	int num,fact=1;
	printf("Enter any Number : ");
	scanf("%d",&num);
	start:
	fact=fact*num;
	num--;
	if(num>1)
	{
		goto start;
	}
	printf("Factorial  : %d",fact);
	return(0);
}
Output

Enter any Number : 5

Factorial  : 120

Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad