Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Factorial Calculation Program in C, Exercises of Computer Engineering and Programming

A simple c program that calculates the factorial of a given number using a for loop. The user is prompted to enter a number, and the program calculates and displays the factorial of that number.

Typology: Exercises

2011/2012

Uploaded on 07/28/2012

dewansh
dewansh 🇮🇳

4.4

(10)

92 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
#include<stdio.h>
#include<conio.h>
void main()
{
long int a,b=1,i;
clrscr();
printf ("Please enter a number\n");
scanf ("%ld",&a);
for (i=a; i>=1; i=i-1)
{
b=i*b;
}
printf("The factorial of the given number is: %ld",b);
getch();
}
Factorial
docsity.com

Partial preview of the text

Download Factorial Calculation Program in C and more Exercises Computer Engineering and Programming in PDF only on Docsity!

#include<stdio.h> #include<conio.h> void main() { long int a,b=1,i; clrscr(); printf ("Please enter a number\n"); scanf ("%ld",&a); for (i=a; i>=1; i=i-1) printf("The factorial of the given number is: %ld",b); getch(); } { b=i*b; }^ Factorial^1 docsity.com