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
You are required to write a calculator for Geometric shapes(Circle, Square, and Rectangle). The basic idea is that you willprovi
denis23 [38]

Answer: The c++ program to calculate area and perimeter for different geometric shapes is given below.

#include <iostream>

using namespace std;

void circle();

void square();

void rectangle();

int main() {  

string shape;

char choice;  

do

{

cout<<"Enter the geometrical shape (circle, square, rectangle)." <<endl;

cin>>shape;  

if(shape == "circle")

       circle();        

   if(shape == "square")

       square();        

   if(shape == "rectangle")

       rectangle();        

   cout<<"Do you wish to continue (y/n)"<<endl;

   cin>>choice;    

   if(choice == 'n')

       cout<<"quitting..."<<endl;        

}while(choice != 'n');

return 0;

}

void circle()

{

   float area, circumference;

   float r, pi=3.14;    

   cout<<"Enter the radius of the circle"<<endl;

   cin>>r;    

   circumference = 2*pi*r;

   area = pi*r*r;    

   cout<<"The circumference is "<<circumference<<" and the area of the circle is "<<area<<endl;    

}

void square()

{

   float area, perimeter;

   float s;    

   cout<<"Enter the side of the square"<<endl;

   cin>>s;    

   perimeter = 4*s;

   area = s*s;    

   cout<<"The perimeter is "<<perimeter<< " and the area of the square is "<<area<<endl;

}

void rectangle()

{

   float area, perimeter;

   float b, h;    

   cout<<"Enter the breadth of the rectangle"<<endl;

   cin>>b;    

   cout<<"Enter the height of the rectangle"<<endl;

   cin>>h;    

   perimeter = 2*(b+h);

   area = b*h;    

   cout<<"The perimeter is "<<perimeter<< " and the area of the rectangle is "<<area<<endl;

}

 

OUTPUT

Enter the geometrical shape (circle, square, rectangle).

circle

Enter the radius of the circle

3.56

The circumference is 22.3568 and the area of the circle is 39.7951

Do you wish to continue (y/n)

n

quitting...

Explanation:

The program performs for circle, square and rectangle.

A method is defined for every shape. Their respective method contains the logic for user input, computation and output.

Every method consists of the variables needed to store the dimensions entered by the user. All the variables are declared as float to ease the computation as the user can input decimal values also.

No parameters are taken in any of the methods since input is taken in the method itself.

4 0
3 years ago
What is a way to Procter your social security number and other sensitive information from identity theft
Morgarella [4.7K]
Hey mate 

by being smart about it and not telling anybody and if u find it no the inter net  call the police  
5 0
3 years ago
Credence is a student in college.
inn [45]

this is hilarious to read

4 0
3 years ago
Read 2 more answers
Categories of general purpose application software and examples each​
avanturin [10]

Answer:

These are the software that you use a lot at home and at school. They are cheap but free from the bug as they are thoroughly tested. And they are easily available as well. Various examples are:

Word processors - These are used to write the memos, letters, and reports. an example is Microsoft word.

Spreadsheet- keep track of accounts. example, Microsoft Excel, Google sheet.

Database application - Keeping track of customer's records. Example Microsoft Access etc.

Desktop publishers- for creating business cards, posters, etc. Example-Microsoft Publisher.

Presentation software - for creating presentations example, Microsoft Powerpoint

Applications for Graphics- for making changes to the images, like Corel Draw

Applications for Web design - creating business websites, and personal. example. Dreamweaver.

Explanation:

Please check the answer.

7 0
3 years ago
Determine the number of cache sets (S), tag bits (t), set index bits (s), and block offset bits (b) for a 1024-byte 4-way set as
Cerrena [4.2K]

Answer:

The answer is The Cache Sets (S) = 32, Tag bits (t)=24, Set index bits(s) = 5 and Block offset bits (b) = 3

Explanation:

Solution

Given Data:

Physical address = 32 bit (memory address)

Cache size = 1024 bytes

Block size = 8 bytes

Now

It is a 4 way set associative mapping, so the set size becomes 4 blocks.

Thus

Number of blocks = cache size/block size

=1024/8

=128

The number of blocks = 128

=2^7

The number of sets = No of blocks/set size

=128/4

= 32

Hence the number of sets = 32

←Block ←number→

Tag → Set number→Block offset

←32 bit→

Now, =

The block offset = Log₂ (block size)

=Log₂⁸ = Log₂^2^3 =3

Then

Set number pc nothing but set index number

Set number = Log₂ (sets) = log₂³² =5

The remaining bits are tag bits.

Thus

Tag bits = Memory -Address Bits- (Block offset bits + set number bits)

= 32 - (3+5)

=32-8

=24

So,

Tag bits = 24

Therefore

The Cache Sets = 32

Tag bits =24

Set index bits = 5

Block offset bits = 3

Note: ←32 bits→

Tag 24 → Set index  5→Block offset 3

7 0
3 years ago
Other questions:
  • Which of the following tends to be true of silent film acting as opposed to sound film acting?
    7·1 answer
  • Because Microsoft Access includes not only the software needed to create a database, but also the software needed to create form
    7·1 answer
  • Who PLAYS Apex Legend?
    10·2 answers
  • 1. What are the built-in operations on classes?
    8·1 answer
  • How many worksheets display in the Excel window when you create a new blank workbook?
    10·2 answers
  • (PYTHON HOMEWORK)Given the following code snippet, which statement tests to see if all three sets are equal?:
    11·1 answer
  • First, read in an input value for variable valCount. Then, read valCount integers from input and output each integer on a newlin
    6·1 answer
  • The _____ method randomly rearranges the items in the list provided in the parentheses.
    5·2 answers
  • ....is an act of introducing an invention into market on business basis for profit​
    12·1 answer
  • What is the two’s compliment of -95,-122,-111,-57
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!