# why are all of them 0

This is a discussion on why are all of them 0 within the C Programming forums, part of the General Programming Boards category; Code: void printFloat() { printf("%f\n",2/3); } int main() { printFloat(); float a = 2/3; printf("%f\n",a); return 0; }...

1. ## why are all of them 0

Code:
```void printFloat()
{
printf("%f\n",2/3);
}
int main()
{
printFloat();
float a = 2/3;
printf("%f\n",a);
return 0;
}```

2. I know:
because 2 and 3 is int type.

3. Yup. You can force it to do the calculation in floating point:
Code:
`2.0/3`
Now because one of the numbers is floating point, the calculation is done that way and the result will be float as well.

4. 2/3 (assuming that's two divided by three) is an integer. Try this.

Code:
```void printFloat()
{
printf("%d\n",2/3);
}
int main()
{
printFloat();
int a = 2/3;
printf("%d\n",a);
return 0;
}```
Output:
Code:
```0
0```
It gives you two zeros because the program sees anything less than one is zero. I think there's a function that gives you the actual decimal, but if you were to get the actual decimal of two divided by three, the screen would flood with sixes.

5. Code:
```void printFloat()
{
printf("%d\n",2/3);
}```
printFloat doesn't actually print a float. You're still using %d, and, you're still using integers.

Quzah.

6. Originally Posted by quzah
Code:
```void printFloat()
{
printf("%d\n",2/3);
}```
printFloat doesn't actually print a float. You're still using %d, and, you're still using integers.

Quzah.
Well zcrself named the function :P