hi
I want to know if there is C code to obtain factorial of any wish number up to 15 digits
I really need this code
hi
I want to know if there is C code to obtain factorial of any wish number up to 15 digits
I really need this code
Where should I mail the code to?
We are happy to assist if you have problem with your code. But you should show your initiatives.
i show my initiatives but now i got to to class
I think you prove that a person's name is a reflection of their personality.
How lazy can you get for f sakes !?
1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
3. Get rid of conio.h and other antiquated DOS crap headers.
4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.
what should i do now? explaining the situation? what do you care about!?
Trying it yourself is usually the first step.
i tried some codes but none work for large numbers.
i upload them
Upload those "codes". Let's take a look at "them".
1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
3. Get rid of conio.h and other antiquated DOS crap headers.
4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.
:">
Code:#include<conio.h> #include<stdio.h> #include<math.h> main() { clrscr(); float n,i; float fact=1; printf("\ninsert the number:"); scanf("%f",&n); for(i=1;i<=n;i++) { fact*=i; } printf("\nthe factorile %f is:\n%f",n,fact); getch(); return 0; }
How does this work for your 15 digits "wish number"?
1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
3. Get rid of conio.h and other antiquated DOS crap headers.
4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.
Main should be declared as int main( void ).
You don't need to be using conio. The screen doesn't need to be cleared at the beginning, and getchar can be used instead of getch.
I think the problem you're trying to get at is that your variables aren't large enough to hold bigger factorials. You should declare your result variable as a larger type (and they need not be floating point types) such as long long int. You'll need to edit some of your input/output calls but that can easily be done by looking at the documentation.