|
-
January 28th, 2003, 10:02 AM
#1
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;
}
--------------------------------------------------------
-
January 28th, 2003, 10:17 AM
#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
Last edited by gjs368; January 28th, 2003 at 10:27 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|