Example Program For Factorial Value Using For Loop In C++


SUBMITTED BY: Nrupeshsinh

DATE: June 24, 2016, 8:24 a.m.

FORMAT: Text only

SIZE: 438 Bytes

HITS: 654

  1. #include<conio.h>
  2. using namespace std;
  3. int main()
  4. {
  5. // Variable Declaration
  6. int counter, n, fact = 1;
  7. // Get Input Value
  8. cout<<"Enter the Number :";
  9. cin>>n;
  10. //for Loop Block
  11. for (int counter = 1; counter <= n; counter++)
  12. {
  13. fact = fact * counter;
  14. }
  15. cout<<n<<" Factorial Value Is "<<fact;
  16. // Wait For Output Screen
  17. getch();
  18. return 0;
  19. }

comments powered by Disqus