# Factorial program using for loop

Page 1 of 1

## 2 Replies - 18719 Views - Last Post: 21 August 2009 - 06:26 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=121604&amp;s=4a8e635f53f785789c3a4b7c0f2e64ec&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 kai44

• New D.I.C Head

Reputation: 0
• 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 ***

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

• Saucy!

Reputation: 6246
• Posts: 24,014
• 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

Reputation:

## Re: Factorial program using for loop

Posted 21 August 2009 - 06:26 PM

Ok... And what's the problem?