Hi all, I am hoping someone can tell me what I am doing wrong. I want to divide two numbers and get a decimal from that, but I cannot figure out how to make this work.
Code:
#include <stdio.h>
#include <stdlib.h>
int main(){
int a=0, b=0;
float c=0;
float d=0;
float f=0;
a = 40749 - 1;
b = 65536 - 1;
c = (a/b);
d = 40748 / 65535;
f = d * 255;
printf("a=%d b=%d c=%d d=%d f=%d\n",a,b,c,d,f);
}
And, when I compile and run, this is what I get (below), c, d, and f all giving back a 0, not a decimal number.
%: gcc test.c
%: a.out
a=40748 b=65535 c=0 d=0 f=0
%:
How do I get a decimal number back? Or, in the case of f, a char/int (because it will be between 0 and 255).