/*
Q. Write a C++ program to find out the factorial of a number using while loop
*/
#include<iostream>
using namespace std;
main()
{
int n,i=1,f=1;
cout<<"\nEnter a number=";
cin>>n;
while(i<=n)
{
f=f*i;
i++;
}
cout<<"\nfactorial ="<<f;
}
Q. Write a C++ program to find out the factorial of a number using while loop
*/
#include<iostream>
using namespace std;
main()
{
int n,i=1,f=1;
cout<<"\nEnter a number=";
cin>>n;
while(i<=n)
{
f=f*i;
i++;
}
cout<<"\nfactorial ="<<f;
}
No comments:
Post a Comment