Factorial program using for loop

I have to make a program that will show a factorial of a number in col

Page 1 of 1

2 Replies - 16560 Views - Last Post: 21 August 2009 - 06:26 PM Rate Topic: -----

#1 kai44  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 11-August 09

Factorial program using for loop

Posted 21 August 2009 - 05:48 PM

#include <iostream>
#include <cmath>
#include<iomanip>
using namespace std;
int main()
{
	int i,j,factorial;

	cout<<"Range Values\t Result Values"<<endl;
	cout<<"------------\t -------------"<<endl;



for(i=1; i<=5; i++)
   {
	cout<<endl<<"     "<<i;

	}
for(j=1; j<=5; j++)
	{ 
	factorial= j*factorial;

   cout << "factorial= " << factorial << endl;
	}
   return 0;
 }


*** MOD EDIT: Added code tags. Please :code: ***

This post has been edited by JackOfAllTrades: 21 August 2009 - 06:26 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Factorial program using for loop

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6066
  • View blog
  • Posts: 23,526
  • Joined: 23-August 08

Re: Factorial program using for loop

Posted 21 August 2009 - 06:26 PM

Are you receiving any errors? Does this code not work that way you intended it? When asking for help there are a couple items that are vital in order for someone to properly help you:
  • Post the code you're having problems with
  • Post the exact error you're receiving, if you are receiving one
  • If no error explain what the code is doing versus what you want it to do
  • Post your question in the body of your post, not the description field

Was This Post Helpful? 0
  • +
  • -

#3 Guest_Neumann*


Reputation:

Re: Factorial program using for loop

Posted 21 August 2009 - 06:26 PM

Ok... And what's the problem?
Was This Post Helpful? 0

Page 1 of 1