New programmer - please help!
I've only just started a course in C Programming, and I've never done any programming before. My exercise asks me to write a program that converts litres into pints and fluid ounces. I have written what I thought was correct, but when running the program it just gives an output of zero for both pints and fluid ounces. The code is:
Code:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main (void)
{
const litres2floz=35.1950652;
float a; //litres
float b=a*litres2floz; //fluid ounces
int c=(b/20); //pints
printf("Enter the number of litres\n");
scanf("%f",&a);
printf("%f litres = %d pints and %f fluid ounces\n",a,c,b-(c*20));
system("pause");
return 0;
}
If anyone can see where I have gone wrong in this it would be a big help.
Thanks guys.