for example 1*2*3*4*5*6

this is what i have:

#include <iostream>

using namespace std;

int main(){
	  

int num =1;
int i; 

for (i=1; i <=20; i++)
{
    num *=i;
    cout<<num<< " * ";
}

system("pause");
	return 0;
}

It is i that you should cout << not num
at least inside the loop
you can cout << " = " << num
after the loop

Whats your error???
Answer not correct?

Use a larger data type ..
instead of

int num=1;

try

long num=1;

or

long long num=1;

it did work man. can you write it.

commented: do it yourself, it's not that difficult -1

it did work man. can you write it.

Are you joking? It's 2 extremely simple changes.

Change num to i inside the loop then add another output line. It's not that hard.

He mean ..

#include <iostream>
using namespace std;

int main(){
long long num =1;
int i; 

for (i=1; i <=20; i++)
{
    num *=i;
    cout<< i << " * ";
}

cout << "=" << num << endl ;
system("pause");
	return 0;
}
commented: Not mean. I actually follow the forum rules. -1

He mean ..

#include <iostream>
using namespace std;

int main(){
long long num =1;
int i; 

for (i=1; i <=20; i++)
{
    num *=i;
    cout<< i << " * ";
}

cout << "=" << num << endl ;
system("pause");
	return 0;
}

Is that so? They're called rules, try following them.

Oopss sorry new to this place ..

Ya.. now your program must works fine ..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.