ruhatadiyaman wrote:
> thanks for all replies. i tried them but still the problem is continuing. 
> this is my code with 'unsigned long int';
> /*factorial*/
> #include<stdio.h>
> int main()
> {
>      int x, y;
>     unsigned long int fak;
>     
>     for(x=1;x<=20;x++){
>                       printf("%d!\t", x);
>                       fak=x;
>                       if(x>=2){
>                       for(y=x;y>=2;y--){
>                                         fak=fak*(y-1);
>                                         }
>                                         }
>                       printf("%lu\n", fak);
>                       }
>     getch();
>     return 0;
> }
> 
> so after 13 the results are wrong :(
> otherwise i confused with usage of long double. i wrote this simple code 
> which is below;
> #include<stdio.h>
> int main()
> {
>     
> long double x, y;
> scanf("%Lf", &x);
> scanf("%Lf", &y);
> printf("x=%Lf y=%Lf\n", x, y);
> printf("result=%Lf", x*y);
> getch();
> }
> 
> when i run it,for example, i give 2 for x and 4 for y,the program gives this;
> x=2.000000  y=0.000000
> result=-2.000000
> 
> what's this?
> 
> best regards

You could also use unsigned long long int and %llu (minimum of 64-bits, 
which will be more accurate than 'float' or 'double').  The following is 
worth keeping around as well for future reference:

http://cubicspot.blogspot.com/2009/03/unsigned-long-long-long-long-long-int.html

-- 
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197

*NEW* MyTaskFocus 1.1
Get on task.  Stay on task.

http://www.CubicleSoft.com/MyTaskFocus/

Reply via email to