# period of the decimal point

+1 vote
sample 1.333333....--------  1.(3).

how we can write program of this?

+1 vote
answered Nov 12, 2019 by Ujaiye
in python, if you want to set the number of decimal point, you set it when you want to display like this:

print ("%.nf" %variable), whereas n is the number of decimal places that you want.

example:

result = 4/3
print ("%.1f" %result)

output=1.3
commented Nov 12, 2019 by (350 points)
example 1.333333333.....--------period of this fraction is 3.we must to find a period part of the fraction(l am sorry ,it is difficult for me to speak in english) and we must to  find this program in c++
+1 vote
answered Nov 13, 2019 by (2,970 points)

I saw in the other comment that you need to do it in C++.

Example program:

#include <iostream>
#include <iomanip>      //important for setprecision() !!!

using namespace std;

int main()
{
double variable = 1.33333333333333333;
cout<<setprecision(1)<<variable;

return 0;
}

It will print out "1.3"

answered Nov 13, 2019 by Karthika Karunakaran
#include <stdio.h>

int main()
{
float x;
x=1.333333;
printf("%.1f",x);
}

output:
1.3
commented Nov 16, 2019 by (350 points)
suppose that you enter number a and b(double a,b)after cin>>a>>b;
we suppose that we entered  1 and 3.we want to find what is the period of this(1/3) fraction.answer of this program must be 3...