#include<iostream>

using namespace std;
int fact (int num);
int main () {
	cout<<"Enter a number"<<endl;
	int number;
	cin>>number;
	cout<<"Displaying number: "<<number<<endl;
	cout<<"Calculating Factorial for the number"<<endl;
	int fact;
	fact = fact(number);
	return 0;
}

 int fact (int num)
 {
 	
 	if(num==1)
 	{
 		return num;
 	}
 	else 
 	{
		return num * fact(num -1);
 	}
 }

This program gives the following error:
fact cannot be used as a function.
could someone help me on this issue

Comments
4 years late with the thread hijack, and no code tags.

@NeoKyrgyz : Did your post add even an inch to what Salem had said ? Was that really necessary ? (Salem's post was the reason many others didn't post because it rectifies everything with respect to this thread.:) and nothing more could be added.)

nothing more could be added.

well... he could rewrite the entire code with full comments, perform validation and coverage metrics, compile release executables and build distribution kits for several major operating systems, then upload the packages to SourceForge and other repositories.

or he could just continue spitting out redundantly obvious answers that others had already pointed out.

either way.

Comments
But still a very useless post. Didn't you just complain about someone else's useless post? ;)
He will now think Oh! So many possibilities are there,it never came to my mind !!! ;) Cool one there buddy !!!

well guys, I thought before posting.
A person who couldn't resolve this kind of error, wouldn't understand the explaination of Salem, which is just a little bit more desciptive than compiler error

"fact cannot be used as a function"

Comments
Disagreed.
Agreed.

i feel ya bro.

it's just the culture here is that we'd rather teach a person to fish than give them fish.

>A person who couldn't resolve this kind of error, wouldn't understand the explaination of Salem.

We all started at that stage itself and we are still learning here so its better not to talk lightly of someone,because we all lack something or the other.

And I would like to mark this in bold with all credits to jephthah :
"It's just the culture here is that we'd rather teach a person to fish than give them fish."

We all started at that stage itself and we are still learning here so its better not to talk lightly of someone,because we all lack something or the other.

That's the point. We all started at that stage, and it's good idea to give more information than compiler does in order to be helpful. I'm not accusing him/her for lack of knowledge, I'm not expert either - but I just wanted to note (inform you) that he's beginner.

And, this is not the place for such discussions, open another thread, I'll reply to you there.

your Mistake is
int fact;
fact = fact(number);
write it like
int f;
f= fact(number);

Comments
hey, don't bother reading the previous 9 posts, or anything.
This article has been dead for over six months. Start a new discussion instead.