Search:
Forum
Beginners
double a number
double a number
Sep 17, 2012 at 8:46pm UTC
javi11
(4)
im new to c++
and i want to know how would i "promt the user to enter a double number"
Sep 17, 2012 at 9:50pm UTC
Armendhammer
(11)
#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.
Sep 17, 2012 at 9:53pm UTC
Armendhammer
(11)
I'm not sure if thats what you wanted. Your question wasnt that good.
Sep 17, 2012 at 9:57pm UTC
Chervil
(7320)
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
).
Sep 17, 2012 at 9:58pm UTC
vlad from moscow
(6539)
@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
Sep 17, 2012 at 9:59pm UTC
Topic archived. No new replies allowed.
C++
Information
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs