Write a program which takes the radius of a circle as input from the user, passes it to another function that computes the area and the circumference of the circle and displays the value of area and circumference from the main() function.




#include<iostream.h>
#include<conio.h>
class factorial
{
int f;
public:
int faci(int f);
int facr(int f);
};
int factorial::faci(int f)
{   int pro=1;
                while(f>0)
                {
                pro=pro*f;
                f=f--;
                }
return(pro);
}

int factorial::facr(int f1)
{
                if(f1<=1)
                return (1);
                else
                return(f1*(facr(f1-1)));
}
void main()
{
clrscr();
factorial obj;
int n1,n2;
cout<<"enter the number whose factorial is to be found by iterative method"<<endl;
cin>>n1;
   cout<<"the answer is "<<obj.faci(n1)<<endl;
cout<<"enter the number whose factorial is to be found by recursive method"<<endl;
cin>>n2;
cout<<"the answer is "<<obj.facr(n2)<<endl;
getch();
}



Output:-

Comments