The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM



Thread: C++ cin problem
View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 05-07-2008
apprentice apprentice is offline
Registered User
 

Join Date: May 2008
Posts: 2
C++ cin problem

Hi, I have recently started using C++. I use g++ on Unix. I could not get a simple C++ program working.

The program is;

#include <iostream>
using namespace std;

int main()
{
double a, b;
cout << "enter your number";
cin >> a;
b = a + 1.15;
cout << b << endl;

return 0;
}

when I run this, I get;
$enter your number1.15

It does not get 'a' from the user. It assumes that 'a' is zero.
Where do I go wrong?
Reply With Quote
Forum Sponsor