Value of pi can be defined as a macro in c or it can be declared as constant division.
it can be determined without learning it . if you search on google , you will get value of pi
but it so big that you can't remember it.
let's see.
consider the computer program :
#include<iostream>
using namespace std;
#define pi 3.141593 // you must remember it for this methord
int main()
{
cout << "area of circle of radius 3 is " << pi*3*3;
return 0;
}
Another methord (best methord ):
#include<iostream>
using namespace std;
const double pi = 22.0/7.0 // you does not have to remember it now
int main()
{
cout << "area of circle of radius 3 is " << pi*3*3;
return 0;
}
refrences:
https://www.quantstart.com/articles/Mathematical-Constants-in-C/
https://stackoverflow.com/questions/1727881/how-to-use-the-pi-constant-in-c
https://www.geeksforgeeks.org/pi-in-c-with-examples/
Comments
Post a Comment