Program to calculate the factorial 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(); }
Pingback: Snake game in C++ codeboks|Learn coding and more Subjects.
Pingback: C++ projects for beginners with source code - Codeboks