Write a program to find the factorial of a number in c++

Hello friends, today we will see you in this blog you'll learn Write a program to find the factorial of a number in  c plus plus| c plus plus coding Tutorials by code with mrinal .Earlier I have shared a blog on Write a program to find the factorial of a number in c plus plus| c plus plus Coding factorial program in c Tutorials by code with mrinal Generally. 



write a program to find the factorial of a number in c++


#include <iostream> 
using namespace std;
 int main()
  { 
 int num, codewithmrinal=1; 
 cout << "Input a number to find the factorial: ";
  cin>> num;
   for (int a=1;a<=num;a++) 
   { 
   codewithmrinal=codewithmrinal*a;
    } 
   cout<<" The factorial of the given number is: "<<codewithmrinal<<endl; 
    return 0; 
    }



Output-- 

Input a number to find the factorial: 4
The factorial of the given number is: 24

[Program finished]


Follow code with mrinal on Instagram https://www.instagram.com/codeswithmrinal ********************************************** 
 Follow code with mrinal on Website https://codewithmrinal.blogspot.com ********************************************** 
 Follow code with mrinal on Twitter https://www.twitter.com/indicoderz ********************************************** 
 Follow code with mrinal on Iinkedin https://www.linkedin.com/indicoderz **********************************************
 Follow code with mrinal on Facebook https://www.facebook.com/codewithmrinal ****************************************** 
 Subscribe code with mrinal on YouTube https://www.youtube.com/indicoderz ********************************************

Post a Comment

Previous Post Next Post