I'm a beginner and I need to know how to work with decimals
My english is very limited however I will try my best to make sense.
#include <stdio.h>
#include <stdlib.h>
main(){
float a, b, c, d, e, f;
scanf ("%f%f", &a, &b);
c=a/b;
d=a/b;
e=c-d
printf ("%.0f rounded", c);
printf ("%f answer", d);
printf ("%f decimal", e);
}
I am a beginner, I have only written VERY simple codes (simple addition, subtraction, writing texts, etc)
I want this code to be able to receive 2 numbers (dividend, divisor) and then give me 2 answers, (one's a whole number, the other one is a decimal)
For example, if I were to write 11 for
a
``` and 2 for
b
"5" and "0.5" instead of "5.50"
I'm able to get the rounded numbers and the exact answer, so I thought I could subtract these two, but I don't know how to make the code save the 2 answers it has given me and subtract them.
(Running the above code, and inputting 11 and 2 I receive "6" and "5.50000", now in order to get "0.50000" I need to subtract "5.50000" from "6" but I don't know how to make the program save the answers it has given me)
Am I on the right track? Or is there a much easier way to do what I want to do?
Thank you for taking your time to read this, any and all suggestions would be helpful. ^^