This is a C program that prompts the user to enter a long integer 'a' and then uses the goto statement to calculate the factorial of the given number 'a'. The factorial of a number is the product of all the positive integers less than or equal to that number.
It is worth noting that the use of the goto statement is generally discouraged in modern programming because it can lead to unstructured and hard-to-maintain code. Alternative control structures such as for loops, while loops or do-while loops can be used for the same purpose and are considered more readable, maintainable and less prone to errors.
Also note that the variable a should be declared as a long int as factorial of large numbers can be very large and can't be stored in a regular integer variable.
#include <stdio.h> int main() { long int a,n=1; printf("\nEnter the number :"); scanf("%ld",&a); start: n=n*a; a--; if(a>0) { goto start; } printf("\nThe Total value is :%ld",n); return 0; }To download raw file Click Here
Enter the number:5 The Total value is:120
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions