GENERAL:Value of PI
//============================================================================
// Name : pi.cpp
// Author : Rohit More
//============================================================================
#include <iostream>
using namespace std;
int main()
{
float pi=22.0/7.0;
int i;
cout<<"Val of pi:";
for(i=1;i<20;i++)
{
cout.width(i+1);
cout.precision(i);
cout<<pi<<"\n";
}
return 0;
}
/*
* OUTPUT
* Val of pi: 3
3.1
3.14
3.143
3.1429
3.14286
3.142857
3.1428571
3.14285707
3.142857075
3.1428570747
3.14285707474
3.142857074738
3.1428570747375
3.14285707473755
3.142857074737549
3.1428570747375488
3.14285707473754883
3.142857074737548828
*
*/
// Name : pi.cpp
// Author : Rohit More
//============================================================================
#include <iostream>
using namespace std;
int main()
{
float pi=22.0/7.0;
int i;
cout<<"Val of pi:";
for(i=1;i<20;i++)
{
cout.width(i+1);
cout.precision(i);
cout<<pi<<"\n";
}
return 0;
}
/*
* OUTPUT
* Val of pi: 3
3.1
3.14
3.143
3.1429
3.14286
3.142857
3.1428571
3.14285707
3.142857075
3.1428570747
3.14285707474
3.142857074738
3.1428570747375
3.14285707473755
3.142857074737549
3.1428570747375488
3.14285707473754883
3.142857074737548828
*
*/
NIce Logic
ReplyDelete