period of the decimal point

+1 vote
asked Nov 11, 2019 by xsevdam (350 points)
sample 1.333333....--------  1.(3).

how we can write program of this?

4 Answers

+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 ("" %variable), whereas n is the number of decimal places that you want.


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

commented Nov 12, 2019 by xsevdam (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 gameforcer (2,950 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;
    return 0;

It will print out "1.3" 

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

int main()
    float x;

commented Nov 16, 2019 by xsevdam (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...
0 votes
answered Nov 13, 2019 by anonymous
By Using Data Type Float we can enter it into our program
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.