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]
2 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]2 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
And then what happened,Paul Revere rhyme
Mamont248 [21]
Wat? Well, huh I don't understand the question
6 0
3 years ago
Read 2 more answers
What color pixels are used in a camera?
Murljashka [212]
Red, blue, and green color pixels are used in a camera
3 0
2 years ago
Read 2 more answers
PLEASE HELP How have phones made us spoiled? How have phones made us unhappy?
Ket [755]
Phones have made us spoiled because we have everything at our fingertips. we get what we want when we see something online and we want to get it all we do is ask and most of us receive. phone have made us unhappy mentally and physically because we see how other people have it like richer for instance and we want that and we get sad about weird things because of what we see like other peoples body’s how skinny someone is and how fat someone is it makes us sad because we just want to be like them.
3 0
2 years ago
I need help!! I decided to go back to college this year and am taking Intro to Logic and Programming. I have an assignment due t
Artist 52 [7]

Answer:

Monday Video: 5.4.20 Section 18.5

Work due: 18.5 Worksheet

CW

Tuesday Video: 5.5.20 Section 18.6

Work due: 18.6 Worksheet

HW

Wednesday Video: 5.6.20 Section 18.7

Work due: 18.7 Classwork

CW

Thursday Video: 5.7.20 Section 18.7

Work due: 18.7 Homework

HW

Friday Video: 5.8.20 Section 18.5-18.7

Work due: Textbook page 615 #5-19 (not #13)

HWaccuracy

Explanation:

7 0
2 years ago
Ultraportable computers will often use ___ technology exclusively, even though their storage capacity is lower than that of a tr
ki77a [65]

Answer:

SSD

Explanation:

8 0
2 years ago
Other questions:
  • Which markup language would be considered the most current for web design? HTLM, HTML5, XHTLM, XHTML 6
    14·2 answers
  • In which situation will file compression be required to complete the task
    15·1 answer
  • According to the video, what education and experience do employers look for in Reporters and Correspondents? Check all that appl
    10·2 answers
  • Consider the following code segment: ArrayList bulbs = new ArrayList(); bulbs.add(new Light()); bulbs.remove(0); bulbs.add(new L
    15·2 answers
  • Write a program to generate personalized junk mail. The program takes input both from an input file and from the keyboard.The in
    14·1 answer
  • How do you reduce computer screen flicker
    11·1 answer
  • Use a switch statement to display "one" if the user has entered 1, "two" if the user has entered 2, and "three" if the user has
    14·1 answer
  • Find the Nearest Repeated Entries in an Array People do not like reading text in which a word is used multiple times in a short
    15·1 answer
  • Activity
    7·1 answer
  • Davingould1115...................answer 2​
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!