Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3026

2/4 = 0 ?

$
0
0
how come 2/4 = 0? here is the code:

Code:

#include <iostream>

int main()
{
        std::cout << 4/2      << '\n'; // ==  2
        std::cout << 0.25*2  << '\n'; // ==  0.5
        std::cout << 2/4      << '\n'; // ==  0????
        std::cin.get();
        return 0;
}


Viewing all articles
Browse latest Browse all 3026

Trending Articles