double a number

im new to c++
and i want to know how would i "promt the user to enter a double number"
#include <iostream>
int main(){
using namespace std;
double user_input;
cout << "Enter a number to double it: ";
cin >> user_input;
cout << user_input<< " times two is " << user_input * 2;
cin.get();
return 0;
}

Sorry I had to type this on a PS3.
I'm not sure if thats what you wanted. Your question wasnt that good.
Breaking this down into stages:

"prompt the user" - output a brief message to tell the user they have to supply some input

"enter a double number" - the user is to supply a number. This will be a double precision floating point number - See double on this page: http://www.cplusplus.com/doc/tutorial/variables/

Finally you need to declare a variable (of type 'double') to store the value, and perform the actual input (probably via cin).
@javi11
im new to c++
and i want to know how would i "promt the user to enter a double number"


It is enough to remove the initial part of the string literal that is instead of

"promt the user to enter a double number"


to use the following string literal :)

"enter a double number: "
Last edited on
Topic archived. No new replies allowed.