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
How to cite a website, like asha.org?
inn [45]
Using the APA style or the<span> American Psychological Association style of referencing or citing sources, the structure for website reference is as follows:
</span>Last, F. M. (Year, Month Date Published). Article title<span>. Retrieved from URL. Hence, for the problem:
</span>Last, F. M. (Year, Month Date Published). Article title<span>. Retrieved from http://www.asha.org</span>
8 0
3 years ago
A hard disk is divided into tracks which are further subdivided into:​
marusya05 [52]

Answer:

sectors

Explanation:

hard disk contain tracks which are further divided into sectors, for storage purposes.

8 0
3 years ago
HELP I WILL MARK BRAINLIEST!!! I NEED ASAP!!!
Alex777 [14]

#This is a way without a loop

friends = list(map(str,input("Enter Names: ").split()))

print(sorted(friends))

#This is a way with a loop (for&&while)

friends = list(map(str,input("Enter Names: ").split()))

cool = True

while cool:

   cool = False

   for i in range(len(friends)-1):

       if friends[i] > friends[i+1]:

           coo = friends[i]

           friends[i] = friends[i+1]

           friends[i+1] = coo

           cool = True

print(friends)

4 0
3 years ago
2. Consider a 2 GHz processor where two important programs, A and B, take one second each to execute. Each program has a CPI of
allsm [11]

Answer:

program A runs in 1 sec in the original processor and 0.88 sec in the new processor.

So, the new processor out-perform the original processor on program A.

Program B runs in 1 sec in the original processor and 1.12 sec in the new processor.

So, the original processor is better then the new processor for program B.

Explanation:

Finding number of instructions in A and B using time taken by the original processor :

The clock speed of the original processor is 2 GHz.

which means each clock takes, 1/clockspeed

= 1 / 2GH = 0.5ns

Now, the CPI for this processor is 1.5 for both programs A and B. therefore each instruction takes 1.5 clock cycles.

Let's say there are n instructions in each program.

therefore time taken to execute n instructions

= n * CPI * cycletime = n * 1.5 * 0.5ns

from the question, each program takes 1 sec to execute in the original processor.

therefore

n * 1.5 * 0.5ns = 1sec

n = 1.3333 * 10^9

So, number of instructions in each program is 1.3333 * 10^9

the new processor :

The cycle time for the new processor is 0.6 ns.

Time taken by program A = time taken to execute n instructions

=  n * CPI * cycletime

= 1.3333 * 10^9 * 1.1 * 0.6ns

= 0.88 sec

Time taken by program B = time taken to execute n instructions

= n * CPI * cycletime

= 1.3333 * 10^9 * 1.4 * 0.6

= 1.12 sec

Now, program A runs in 1 sec in the original processor and 0.88 sec in the new processor.

So, the new processor out-perform the original processor on program A.

Program B runs in 1 sec in the original processor and 1.12 sec in the new processor.

So, the original processor is better then the new processor for program B.

5 0
2 years ago
What unit is used to describe the smallest amount of bitcoin?
diamong [38]

Answer:

The satoshi is currently the smallest unit of the bitcoin currency recorded on the block chain. It is a one hundred millionth of a single bitcoin (0.00000001 BTC).

Explanation:

A bitcoin is a type of digital currency in which a record of transactions is kept and new units of currency are generated by the computational solution of mathematical problems. Bitcoins operate independently through a central bank.

7 0
2 years ago
Other questions:
  • I. Given the following Java code fragment, what is output? int a, b; String c, d, e; String x = new String("I LOVE"); String y =
    14·1 answer
  • Helena purchased a security software package to protect her new laptop against threats such as spyware and computer viruses. she
    14·1 answer
  • What are three softwares for cloud computing
    8·1 answer
  • Randy earn $22 per hour. This is an example of
    11·1 answer
  • Why can’t I “change the country” on settings??<br> (In this app)
    13·1 answer
  • What is the term used to describe a computer system that can store literary documents, link them according to logical relationsh
    5·1 answer
  • The
    6·1 answer
  • A motor is controlled by a logic circuit. The circuit has inputs (0 or 1) from three sensors
    8·1 answer
  • Why would researching the average earnings by major and by career be useful to you as you choose an institute for higher educati
    10·1 answer
  • How to send an email to multiple recipients individually outlook
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!