Question #31372

write a function double get_double(string promt) that displays the prompt string, followed by a space, reads a floating-point number in, and returns it.

Expert's answer

#include <iostream>
#include <string>

using namespace std;

float get_double(string promt){
return atof(promt.c_str());
}
//main function
int main()
{
//input string
string input="";
cout<<"Enter string: ";
cin>>input;
//show result
cout<<get_double(input);
return 0;
}

LATEST TUTORIALS
APPROVED BY CLIENTS