Write a program to calculate the factorial of any number using do while loop

Program to calculate the factorial using do while loop

Write a program to calculate the factorial of any number using do while loop

Object: Write a program to calculate the factorial of any number using do while loop. C++ projects for beginners with source code

Code:

#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
int i=1,no,fact=1;
cout<<” Enter Any Number: “;
cin>>no;
do
{
fact=fact*i;
i++;
}while(i<=no);
cout<<“\n Factorial of given Number is: “<<fact;
getch();
}

#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
	int i=1,no,fact=1;
	cout<<" Enter Any Number: ";
	cin>>no;
	do
	{
		fact=fact*i;
		i++;
	}while(i<=no);
	cout<<"\n Factorial of given Number is: "<<fact;
	getch();
}

 

Output:

Write a program to calculate the factorial of any number using do while loop

2 thoughts on “Write a program to calculate the factorial of any number using do while loop”

  1. Pingback: Snake game in C++ codeboks|Learn coding and more Subjects.

  2. Pingback: C++ projects for beginners with source code - Codeboks

Leave a Comment

Your email address will not be published. Required fields are marked *