Answer:
Following are the program to this question:
#include <iostream> //defining header file
#include <fstream>//defining header file
using namespace std;
int main()//defining main method
{ string name; //defining string variable
int age; //defining integer variable
cout << "Enter your name: "; //print message
getline(cin, name); //input value using getline method
cout << "Enter your age: "; //print message
cin >> age; //input value
ofstream outdata("outdata"); //using ofstream method
outdata << name << " " << age << endl; //print value
outdata.close(); //closing outdata.
return 0;
}
Output:
Enter your name: dev
Enter your age: 22
please find the attachment.
Explanation:
Description of the above can be described as follows: