wap c++ program to print factorial number using class and object
#include<iostream>
using namespace std;
class rohit
{
int n, n1,fact=1;
public:
void input();
void calc();
void display();
};
void rohit::input()
{
cout<<" enter the number of factoril "<<endl;
cin>>n;
}
void rohit::calc()
{
n1=n;
if(n==0||n==1)
{
cout<<"fact is 1"<<endl;
}
else{
while(n>0)
{
fact=fact*n;
n--;
}
}
}
void rohit::display()
{
cout<<"fact is ="<<fact<<endl;
}
int main()
{
rohit s;
s.input();
s.calc();
s.display();
return 0;
}
========================================================================
** if there is no program available then pls. go to top right section and search it
#dynamiteRohit thanks :)
No comments:
Post a Comment