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
Which of the following is a list of input devices?
charle [14.2K]
The Correct answer would be C. <span>microphone,mouse,scanner

microphone you talk into to give info (data)

a mouse you use to click on objects  to give input 

a scanner you input a paper/object 

hope this helps!! :)


</span>
7 0
3 years ago
which of the following peripheral does not belong to a group: A) Monitor B) Printer C) Hardware D) Keyboard​
nikdorinn [45]
C hardware is the correct answer
5 0
3 years ago
How to solve level 53 on rapid router?
alexgriva [62]

&lt;img src=/static/game/image/actions/go.svg alt=' + ugettext(play= button)= += '= style=width: 4%;&gt; ) def noPermissionMessage():

6 0
2 years ago
What is one advantage of using object-oriented programming?
maxonik [38]
That answer would be B hope it helps
6 0
3 years ago
Read 2 more answers
Use the drop-down menus to complete the statements about using column breaks in word 2016
Ugo [173]

Answer: layout, section, number, more options

Explanation:

Just did it on edge 2020

4 0
3 years ago
Read 2 more answers
Other questions:
  • What is Least effective at preventing a computer virus
    10·1 answer
  • Don't pat any attention to this
    7·2 answers
  • In this problem, we explore some of the properties of the CRC. For the generator G (=1001) given in Section 5.2.3, answer the fo
    6·1 answer
  • What is a central location that houses Joint Information System (JIS) operations and where public information staff perform publ
    6·1 answer
  • A digital designer might do computer animations for video games,<br> OA<br> True<br> OB<br> False
    12·2 answers
  • True or False(T or F): Point-and-shoot cameras have only 1 lens. *
    5·1 answer
  • Can someone please help me I need to turn this in my 3:00pm Eastern time
    12·1 answer
  • For which input values will the following loop not correctly compute the maximum of the values? 1. Scanner in = new Scanner (Sys
    14·1 answer
  • 1.
    7·1 answer
  • What online resource would you use if you wanted to read a review about a new movie?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!