Hay guys, i wanted to get the code for a very large factorial but i was unable to do so. Now, i had to work and develop the code myself, which i did.
This code calculates factorial of numbers uptil 14000. . i havent tried more. But i guarantee this code's working. I hope you will find this code helpful.
Atleast u'll not have to waste time like i did!!!!

// GROUP 12
// Group members:Aniqa Hayee(091105), Nimra Mustafa(091133), Javeria Raja(091120)
// BS(CS)-Semester I-Section B
//Computer Programming
//Project:To calculate the factorial of a large number

void main()
	long k;
	cout<<"Enter a number whose factorial needs to be calculated:";
/////////////////code for numbers which are less than 33 and greater than 3///////////////////////////////////////////////////////////
if (k<=33)
		unsigned double long fact=1;
		for(int b=k;b>=1;b--)
		cout<<"The factorial of "<<k<<" is "<<fact<<endl;
////////////////code for numbers which are greater than 33 ///////////////////////////////////////////////////////////

	int numArr[10000];
	int total,rem=0,count;		//rem use to save remainder of division(Carry Number).
	register int i;             //register will enhance performance by minimizing access time
	//int i;
		numArr[i]=0;            //set all array on NULL.

	numArr[10000]=1; //start from end of array.

			total=numArr[i]*count+rem;  //rem will add the carry number to the next array digit that is multiplied to the count
				numArr[i]=total;   //numArr[i] is being accessed in this for loop because we have made i as register which means the memory is allocated 

	cout<<"The factorial of "<<k<<" is ";

		if(numArr[i]!=0 || count==1)  


and yes. . . .this is the easiest code there is. . . u'll understand it just as u keep reading it!!

This code won't work. The very first line is already wrong: #include<iostream.h> . Any compiler from the last decade will tell you "include file not found".
At that's just the first of many problems with standard-C++ in your code.

Atleast u'll not have to waste time like i did!!!!

How can it be a waste of time when you learn how to do something? You're basically just preemptively doing everyone's homework for them with this code snippet (seeing as how this program was homework, judging by the file comment).

Anyway, the code is filled with assumptions and poor practices. Here are a few of the ones that stick out:

Not standard, becoming more and more scarce as modern compilers start refusing to compile it.

>void main()
main returns int. It always has, even back to the prehistory of C (C++'s primary parent language).

>if (k<=33)
You're making assumptions about the range of long double.

>//register will enhance performance by minimizing access time
In practice, register will probably be ignored by your compiler. Even if this hint is honored, the effect is likely to be detrimental as the compiler is far better at allocating registers than an application programmer. As such, adding restrictions when there's no guaranteed (or even likely) benefit is silly.

>int numArr[10000];
The array size is an unwarranted assumption.

>numArr[10000]=1; //start from end of array.
You mean start by overflowing the array. In an array of 10000 elements, the last accessible index is 9999.

>//numArr is being accessed in this for loop because we have
>made i as register which means the memory is allocated

Um, i is an automatic variable anyway (as is numArr). If you got to this point, it's allocated, regardless of being declared as register or not. Your comment is nonsensical and unnecessary.

commented: Narue is a surgeon of code +1
commented: Go get 'em! +18

Well, i have used this program in visual C++ 6.0. And it works perfectly. And i have n't posted this code without consulting a proper teacher. I am a beginner, and so this code has been checked by a proper teacher. I don't know what compiler you are using, but this code works positively and perfectly for me!
if this code helps people, i'll be very happy.

If you are really interested in learning C++ and becoming a good programmer, take all this advice constructively. Tomorrow when you go out to work in the professional world and do these mistakes, no one will point them out to you, they would probably just fire you. So, there's no point becoming all obstinate about your code, you are in-fact lucky that you got your code reviewed by such good programmers and got all this feedback.
Be wise and try to understand every bit of what's given and importantly, don't take your teacher's word as final.

commented: Very nice suggestion :) +6
commented: nice one! +1

> Well, i have used this program in visual C++ 6.0.
VC6 is over 10 years old. The world has moved on, and so have the standards for C++.

> And i have n't posted this code without consulting a proper teacher.
Ever hear the adage "those that can, do; those that can't, teach"?
It is our considerable experience which suggests there are a lot of teachers out there who couldn't find their own ass in the dark, nevermind teach C++ (or programming in general) with any degree of competence.

Just because someone who claims to be your teacher has checked the code does NOT make it bug free (Narue trivially proved this to be the case with your array overstep), but your teacher didn't spot that did they?

In the real world (if you hope to program beyond college), your code will be reviewed many many times by lots of people with vastly more experience of programming than either you or your teacher. Mistakes will always be found.

>Well, i have used this program in visual C++ 6.0. And it works perfectly.
It crashes and burns in Visual C++ 2005 and 2008, but that's after I fix the code to be more standard. Before that it doesn't even compile. I guess you're behind the times. Not a good thing when you're likely to use the more modern versions out in the real world.

>I am a beginner, and so this code has been checked by a proper teacher.
Yes, you are a beginner. And this code may have been checked by a teacher, but certainly not a proper teacher. A proper teacher would have seen the glaring overflow bug.

>Mistakes will always be found.
Yes, and it's preferred that mistakes be found before the code goes live. Because fixing a mistake in production is far more expensive and time consuming than fixing a mistake during development.

Guys please check the Logic ...Dont go by syntax ,any one can fix this compilation error later on,you should focus on the logic what he is written .
And dont forget in professional life no one starts with blasting people learn from failure.Any way gCC when you compile that code it will give the warning whatever you guys have pointed out.So its not a big deal to fix them

unsigned long double is false declaration .
float and double date type must be signed number.
sign bit is the first bit of them memory style.

I dont know why everyone complains about small things when someone achieves something astronomical. If this is code is indeed written by the named people, the have done terrific job! Thank you, I will follow the steps you have written and understand it to see if I can implement in other problems as well.
Thank you.

This problem is asked in project euler problem 20