-
Beginner in C++
Hi
I have written the progam below.Its very basic.
I am getting the output 2 but i expect to get 2.5
Can any one help
-----------------------------------------------------
#include <iostream>
int main()
{
double input = 0.00; // no of sequences
input = 5 / 2;
cout << " Output " << input << endl;
}
--------------------------------------------------------
-
The most likely cause of what you see is that you are doing a division of ints and assigning the value to a double after the division is done. Try