new here

hi i'm new here, i just started a class for C++ and i need a little help.
can somebody give an example in a program how to take a 2 given numbers, one as a numerator and one as a denominator, and place it in fractional form?
ie...type in 1 for numerator and 2 for denominator and then display the result as

1
-
2
i need 3 programmer-defined functions: count_digits, print_fraction and print_line.
the number of "-" between 1 and 2 needs to coordinate with the biggest number of either the numerator or denominator.
thanks for any help
Last edited on
Well, basically, just take both of the numbers into strings, then make a function count_digits that returns the .size() of the strings. Then you can compare those numbers and print it out.
can you write that in C++?
I would, but it would be better if you figured out how to do it yourself, since that is what the class is for.
alright well i got it kinda figured out
heres my loop for print_line function

/*Print_line function*/
void print_line(int n);
for(n;n<=9;)
printf("-");

i can't get the loop to stop printing "-" though
You forgot the increment:
1
2
for (; n <=9; ++n) /* note the ++n */
  printf("-");


I hope it works for you! ^_^
Last edited on
u coudl do like

int a=1;
int b=2
int main(){
cout << a << endl << "-" << endl << b <<endl;
system("PAUSE")
return 0;
}

like that but put in headers and such
Topic archived. No new replies allowed.