Friday, 5 February 2021

Program to find factorial of a number using class in C++

 #include<iostream>

using namespace std;

class Factorial

{

    public:

    int f=1,n,i;

    

   void Fact()

   {

       cout<<"Enter a Number\n";

       cin>>n;

       for(i=1;i<=n;i++)

       f*=i;

       cout<<"Factorial of "<<n<<" is "<<f;

   }

};

    main()

    {

        Factorial obj;

        obj.Fact();

    }

No comments:

Post a Comment

Java Program to count the total number of characters in a string

 //Java Program to count the total number of characters in a string import java.util.*; public class CountChars {     public static void mai...