Practical : 13
Subject : Object Oriented
Programming with C++
Aim : C++ program to calculate factorial of a given number
Source Code :
#include<iostream.h>
#include<conio.h>
class copy{
inta,b;
public:
copy(int t)
{
a=t;
}
double c()
{
b=1;
for(int i=1;i<=a;i++)
{
b=b*i;
}
return b;
}
};
void main()
{
int n;
clrscr();
cout<<"\n\t Enter the no :";
cin>>n;
copyobj(n);
copy copy=obj;
cout<<"\n\t"<<"factorial is :"<<obj.c();
getch();
}
Output :
0 comments:
Post a Comment