Home › Forums › C Programming › Basic C Help — Currency Converter › Re: Re: Basic C Help — Currency Converter
June 1, 2009 at 10:14 pm
#3451
Participant
could do something like this ( I’m not real good with stdio.h , In school I used iostream.h ) :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <br /> <br /> /*<br /> Takes currency input from user and outputs currency conversions for USD, GBP, CAD,<br /> EUR, AUD, CYN (Chinese Yuan)<br /> */<br /> <br /> #include <stdio.h><br /> #include <stdlib.h><br /> <br /> main()<br /> {<br /> <br /> /* Declare and Initialize Variables */<br /> const float USD = 1.0000;<br /> const float GBP = 0.5653;<br /> const float CAD = 1.0637;<br /> const float EUR = 0.7006;<br /> const float AUD = 1.2335;<br /> const float CYN = 6.8400;<br /> const float UserInput = ' ';<br /> <br /> /* Begin user interaction */<br /> <br /> <br /> //could use printf ( "%20,-c" , '-' ); for this ( vc++ dosen't seem to like printf options )<br /> printf("| <hr class="bbcode_rule" /> |n");<br /> printf("%10s", "|" );<br /> printf( "%8s" , "USD" );<br /> printf( " | " );<br /> printf( "%8s" , "GRP" );<br /> printf( " | " );<br /> printf( "%8s" , "CAD" );<br /> printf( " | " );<br /> printf( "%8s" , "EUR" );<br /> printf( " | " );<br /> printf( "%8s" , "AUD" );<br /> printf( " | " );<br /> printf( "%10s" , "CYN |n" );<br /> printf( "%10s" , "DOL |" );<br /> printf( "%8.2f" , CYN ); //using CYN as every value for example<br /> printf( " | " );<br /> printf( "%8.2f" , CYN );<br /> printf( " | " );<br /> printf( "%8.2f" , CYN );<br /> printf( " | " );<br /> printf( "%8.2f" , CYN );<br /> printf( " | " );<br /> printf( "%8.2f" , CYN );<br /> printf( " | " );<br /> printf( "%8.2f" , CYN );<br /> printf( "|n" );<br /> <br /> return 0;<br /> }<br /> |
heres a good link on some of the printf() options: http://www.thinkage.ca/english/gcos/expl/c/lib/printf.html