Expand|Select|Wrap|Line Numbers
- #include <iostream>
- using namespace std;
- int main()
- {
- float average;
- float average2;
- average=3.5;
- average2=(7/2);
- cout << average << endl;
- cout << average2 << endl;
- return 0;
- }
3.5
3
If average2 is a float and is being set equal to (7/2) why isn't it 3.5 instead of 3? I know for int values it drops off the remainder or decimal but if average2 is a float why won't it keep the decimal? It's probably something really easy or stupid I've forgotten.
Thanks.