Displaying numbers to two decimal places using printf
Hey
I am currently in uni and I have just started to learn basic C. For a project, I have to make a simple application that can convert GBP into euros (roughly). The problem I have is displaying the input and the output as a decimal number.
Here is my code:
Code:
/* Currency conversion app
Kieran Symes */
#include <stdio.h>
void welcome(void); //displays welcome message and app info
void convert(void); //converts users input to $
int main()
{
welcome();
convert();
return 0;
}
//this bit welcomes the user and shows some info
void welcome(void)
{
printf ("Currency Converter\nBy Kieran Symes\n24/10/2006\n\n");
}
void convert(void)
{
float input;
float output;
printf("Please enter an amount you wish to convert\n");
scanf("%f", &input);
output = input * 1.5;
printf("£%f is equal to %f euros.", input, output);
}
The output for this, say if I enter 21 is
£21.000000 is equal to 31.500000 euros. but I want these figures to be displayed in currency format.
Any help and comments will be appreciated. Thanks