I'm having problems getting this to work correctly and when I try to run it from the command line I get a Segmentation error. This program is for approximating the number using Farey Sequence. At the end of the loop the output needs to be in fraction form, the restrictions are for the loop to stop when either the
mediant denominator is larger than 1,000,000 or when the mediant is within 10-6
of x. Also the program should read the value of x from the command line, rather than prompting for it.
The reason is argv[1] is otherwise out of range given the way you are programming reading argv[]. Normally it is done with a loop based on the value of argc.
also i want my x value to be inputed directly from the command line (i am compiling and running this on ubuntu). I am unsure how to do this.
When I try: ./a.out 0.324235345
^some random value
into the command line nothing happens. I have to close out the terminal completely in order to type any new commands. What's happening to my cout? Why does no value for my mn/md appear?
ok. so i got it to work. It didn't have anything to do with x, and that is all working properly as is (I tried both with and without it). However, the problem now seems to be that the while loop isn't listening to my conditions. The only way I can get correct results is if I use || but i want the program to adhere to BOTH conditions (but I don't get acurate results with &&). Any ideas?