Click to See Complete Forum and Search --> : Beginner in C++


Sarika73
January 28th, 2003, 09:02 AM
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;

}

--------------------------------------------------------

gjs368
January 28th, 2003, 09:17 AM
input = 5 / 2; 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 input = 5.0/2.0