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
Ad libitum [116K]
3 years ago
6

Read first a user's given name followed by the user's age from standard input. Then use an ofstream object named outdata to writ

e 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:
Stells [14]3 years ago
8 0

Answer:

/*

* Program to write data to text file.

*/

#include<iostream>

#include<fstream>

#include<string.h>

using  namespace std;

int main()

{

//Variable to name and age of a person.

string name;

int age;

cout<<"Enter your name"<<endl;

cin>>name;

cout<<"Enter your age"<<endl;

cin>>age;

     //Creating object of ofstream.

   ofstream file;

   file.open ("outdata.txt");

   //Writing data to file named outdata.txt

   file<<name<<" "<<age;

   file.close();

 

}

Output:

Enter your name

John

Enter your age

25

Content of Output.txt:

John 25

Explanation:

To write data to a file  ofstream object is used. An ofstream object file is created first and then using this object a file named "outdata.txt" is created.

Finally using shift operator (<<), by means  of operator overloading, name and age of  person is transferred to file outdata.txt.

You might be interested in
What is the aspect ratio of this photo?<br> A) 29.97<br> B) 1:1<br> C) 4:3<br> D) 9:16<br> E) 1080p
UkoKoshka [18]

Answer:

1080p

Explanation:

3 0
2 years ago
Other than a desktop computer, laptop, tablet ,or cell phone, discuss two other ways computers are used on our daily lives
Vaselesa [24]
For emails, work, that is what I think if you think it’s wrong it’s okay :D
5 0
3 years ago
Difference between automated testing and manual testing
My name is Ann [436]

Answer:

In manual testing, a human performs the tests step by step, without test scripts. In automated testing, tests are executed without human assistance, oftentimes via test automation frameworks, along with other tools and software.

Explanation:

8 0
4 years ago
⭐️⭐️ help with python - check image ⭐️⭐️
alukav5142 [94]

I don't know of the top of my head, but try stack overflow for anything coding related.

8 0
3 years ago
Read 2 more answers
The primary input device for interacting with the operating system is the ____.
andre [41]
The primary input device is the Mouse.
3 0
3 years ago
Read 2 more answers
Other questions:
  • The students of a college have to create their assignment reports using a word processing program. Some of the questions in thei
    9·1 answer
  • In the context of prototyping during the design phase of the systems development life cycle (SDLC), a _____ prototype shows user
    14·1 answer
  • A patient asks her doctor to send a copy of her records to another medical office. However, the records are not transmitted beca
    10·2 answers
  • HOW CAN YOU CHANGE YOUR BACKGROUND
    12·1 answer
  • List the six external parts or "peripherals" of a computer system and identify which are the output and which are the input devi
    6·1 answer
  • A dictionary password attack is a type of attack in which one person, program, or computer disguises itself as another person, p
    5·1 answer
  • Once we have reached complete efficiency in the third part of the LRAS Curve, what occurs?
    10·1 answer
  • Why did my typing suddenly become delayed, but then went back to normal a few minutes later. Is this spyware or smth?
    6·1 answer
  • The technique helps you explore possible risks by providing access to risk areas identified in the past. It also provides the so
    10·1 answer
  • What is the answer to 4.9 Code Practice: Question 2
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!