How to printf long long

前端 未结 4 999
南旧
南旧 2020-11-30 10:48

I\'m doing a program that aproximate PI and i\'m trying to use long long, but it isn\'t working. Here is the code

#include
#include

        
4条回答
  •  半阙折子戏
    2020-11-30 11:26

        // acos(0.0) will return value of pi/2, inverse of cos(0) is pi/2 
        double pi = 2 * acos(0.0);
        int n; // upto 6 digit
        scanf("%d",&n); //precision with which you want the value of pi
        printf("%.*lf\n",n,pi); // * will get replaced by n which is the required precision
    

提交回复
热议问题