Hey there. Im taking a beginners course in c programming and i'm stuck. Im trying to add an integer and double, but the sum is showing only the integer value and not the result? here's the code:
int main (void)
{
// declare variables
int a;
double b;
double purchasePrice;
printf("\nNumber of items purchased\n");
scanf("%d",&a);
// (printf)Prompt user for number of items
// Take user input for number of items (scanf)
printf("\nEnter the Unit Price\n");
scanf("%.2f",&b);
// (printf) Prompt for unit price
// take user input for unit price (scanf)
purchasePrice = a + b;
printf("\nPurchase Price is %.2f\n",purchasePrice);
int main (void)
{
// declare variables
int a;
double b;
double purchasePrice;
printf("\nNumber of items purchased\n");
scanf("%d",&a);
// (printf)Prompt user for number of items
// Take user input for number of items (scanf)
printf("\nEnter the Unit Price\n");
scanf("%.2f",&b);
// (printf) Prompt for unit price
// take user input for unit price (scanf)
purchasePrice = a + b;
printf("\nPurchase Price is %.2f\n",purchasePrice);