1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
spin [16.1K]
4 years ago
8

Write a program that read first a user's given name followed by the user's age from standard input. Then use an ofstream object

named outdata (which you must declare) to write this information separated by a space into a file called outdata. Assume that this is the extent of the output that this program will do. Declare any variables that you need.

Computers and Technology
1 answer:
mr_godi [17]4 years ago
3 0

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:

  • In the main method, two variable "name and age" is declared, in which name is string variable, and age is an integer variable, in both variable, we take user input, but in the name variable, the inline method is used, that take input from the user end.
  • In the next step, ofstream method is used, which creates an object "outdata", which prints user input value in the "outdata" file separated by a single space.

You might be interested in
which network component connects a device to transmission media and allows the device to send and receive messages?
krok68 [10]

Answer: Hello!

Network Interface Card (NIC)

Explanation:

Mark me brainest please. Hope I helped! Hope you make an 100%

-Anna♥

5 0
3 years ago
So my computer has be clicking random things and opening things. It’s been happening for a few days and I want to know if it’s a
soldi70 [24.7K]

Viruses and malware are common and can have drastically negative results on your computer and life.

You can often tell that your computer is infected because it acts weird or slow.

Active antivirus software is a good way to prevent these problems.

4 0
3 years ago
You have posted some embarrassing photos of a friend onto the Internet. After
e-lub [12.9K]

Answer:

C

Explanation:

4 0
3 years ago
You should always ___ before exiting the park vehicle
ivolga24 [154]
Get your trash and belongings
5 0
4 years ago
You want to buy a truck. You need to decide on whether you want to buy a new
alekssr [168]

Answer 12000

Explanation:

7 0
3 years ago
Other questions:
  • Create a stack with three integers and then use .toarray to copy it to an array.
    10·1 answer
  • Which task can be completed using the Export File menu?
    5·1 answer
  • Is data mining a simple transformation or application of technology developed from databases, statistics, machine learning, and
    12·2 answers
  • What option from the format tab should you use to remove unwanted parts of a picture
    8·1 answer
  • What is output? Select all that apply. c = 3 while (c &lt; 10): c = c + 2 print (c)
    6·1 answer
  • 7.4 code practice question 1 edhesive
    15·2 answers
  • What is an a free open source content management system for publishing web content​
    8·1 answer
  • What underlying concept is edge computing based on?
    13·2 answers
  • Write a code segment that will store a dinner selection in option1 based on the values of rsvp and selection. The intended behav
    5·1 answer
  • Francisco is becoming a dad for the first time. He feels relatively clueless about all things involving parenting and is looking
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!