0 votes
2.5k views
in Programming by (98.9k points)
edited
Write a program in C++, to find factorial of a given number using function void

1 Answer

0 votes
by (98.9k points)
selected by
 
Best answer

#include <iostream>

#include <conio.h>

using namespace std;


void fact(int num); 

int main(void)

{

   int num;

    cout<<"Enter the number to find factorial\n";

    cin>>num;

    fact(num);

    getch();

    return 0;

}

void fact(int num)

{

    int i,f=1;

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

    {

   f=f*i;

     }

cout<<"Factorial of "<<num<<"is:"<<f;

    

}


Output::

Related questions

0 votes
1 answer 1.5k views
0 votes
1 answer 354 views

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

554 users

...