Answer:
See explaination for program code 
Step-by-step explanation:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main() {
 string name;
 int age;
 cout << "Enter name of user: ";
 getline(cin, name);
 cout << "Enter age of user: ";
 cin >> age;
 ofstream outdata("outdata");
 outdata << name << " " << age << endl;
 outdata.close();
 return 0;
}