Create three functions called prompt( ) that perform this task for data of types int, double, and long
#include <iostream>
using namespace std;
void prompt(char *str, int *i);
void prompt(char *str, double *d);
void prompt(char *str, long *l);
int main(void){
int i;
double d;
long l;
prompt("Enter an integer: ", &i);
prompt("Enter a double: ", &d);
prompt("Enter a long: ", &l);
cout << i << " " << d << " " << l;
return 0;
}
void prompt(char *str, int *i)
{
cout << str;
cin >> *i;
}
void prompt(char *str, double *d)
{
cout << str;
cin >> *d;
}
void prompt(char *str, long *l)
{
cout << str;
cin >> *l;
}
Related examples in the same category