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
with the current computer development, explain 5th areas where computer is applied for the social economic dwvelopment in societ
AleksandrR [38]

Explanation:

just want points tbh but have a good day

7 0
3 years ago
What are three responsibilities of an operating system? please answer quick!!!
Dennis_Churaev [7]
Same here thank you
3 0
3 years ago
The ___________ method returns the length of an array.
MaRussiya [10]

Answer:

A. Append

Explanation:

4 0
2 years ago
Read 2 more answers
JAVA
Umnica [9.8K]

import java.util.Scanner;

public class JavaApplication58 {

   

   public static void main(String[] args) {

       Scanner scan = new Scanner(System.in);

       System.out.println("Enter a positive integer:");

       String num = scan.nextLine();

       for (int i = num.length()-1; i >=0; i--){

           System.out.println(num.charAt(i));

       }

       

   }

   

}

I hope this helps!

5 0
3 years ago
What are the 5 general terms of the fair use rule
Andrews [41]

the purpose and character of your use.

the nature of the copyrighted work.

the amount and substantiality of the portion taken, and.

the effect of the use upon the potential market

In its most general sense, a fair use is any copying of copyrighted material done for a limited and “transformative” purpose, such as to comment upon, criticize, or parody a copyrighted work. Such uses can be done without permission from the copyright owner

the nature of the copyrighted work; the amount and substantiality of the portion used in relation to the copyrighted work as a whole; and. the effect of the use upon the potential market for or value of the copyrighted work

uwu hope dis halpz!

5 0
3 years ago
Other questions:
  • Erick, who is taking an online course, sent an e-mail to his
    14·2 answers
  • What is the height of the tallest possible red-black tree containing 31 values?
    7·1 answer
  • What are some objects in your home that demonstrate electrical energy to radiant energy to thermal energy
    10·2 answers
  • In a CPMT, a(n) ____ should be a high-level manager with influence and resources that can be used to support the project team, p
    10·1 answer
  • What do you think was the immediate effect of the introduction of handheld consoles and video games?
    6·1 answer
  • I CANT DO SKIN MODS ON BRAWLHALLA RIGHT!!!! IM SO MADDDDDDDDDDD
    11·1 answer
  • Please help it’s timed
    5·1 answer
  • Pls help... : Slide layouts can be changed by _____.
    9·1 answer
  • Explain Http and Ftp​
    12·1 answer
  • What Does The Computer Monitor Contain?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!