#include <stdio.h>
#include <math.h>
int main() {
int a =2;
int b =4;
int c =6;
int d =8;
int currencyOption;
printf("\n *********************************************");
printf("\n *********************************************");
printf("\n ** Enter the number from the below list ** ");
printf("\n ** of currency you wish to convert to US$ **");
printf("\n ** **");
printf("\n ** **");
printf("\n ** 1 = Australian dollars. **");
printf("\n ** 2 = British Pounds. **");
printf("\n ** 3 = Japanese yen. **");
printf("\n ** 4 = Vietnams dollars. **");
printf("\n ** **");
printf("\n ** Enter Currency number: **");
printf("\n ** **");
printf("\n *********************************************");
printf("\n *********************************************");
printf("\n");
scanf("%d", ¤cyOption);
printf("\n");
float xrate;
if(currencyOption == 1) {
xrate=1.078;
printf("You want to convert Australian dollars to US$ \n"); }
if(currencyOption == 2) {
xrate=0.656;
printf("you want to convert British pounds to US$ \n"); }
if(currencyOption == 3) {
xrate=98.309;
printf("you want to convert Japanese yen to US$ \n"); }
if(currencyOption == 4){
xrate=21025.0;
printf("you want to convert vietnames dollars to US$ \n"); }
printf("\n");
printf("\n **************************************************");
printf("\n **************************************************");
printf("\n ** **");
printf("\n ** Enter the amount you wish to convert to US$ **");
printf("\n ** **");
printf("\n **************************************************");
printf("\n **************************************************");
printf("\n");
float currencyvalue;
printf("\n");
scanf("%f",¤cyvalue);
int i=1;
float result[2];
int mult = i* 1;
result[i] = currencyvalue * xrate * mult;
printf("\n");
printf("\n");
printf(" %f To Be Converted\n\n Exchange rate of %f \n\n US$%f will be recieved\n--------------------\n", currencyvalue, xrate, result[i]);
printf("\n");
return 0; }
You can control printf by specifying something like "%7.3f" - this will give you three decimal places, and the number will be filled with spaces on the right side to make it 7 positions in total.