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
SashulF [63]
3 years ago
8

Write a program that first calls a function to calculate the square roots of all numbers from 1 to 1,000,000 and write them to a

file named: roots.txt (See output on page 3) 2.) Write a program then calls a function to calculate the squares of all numbers from 1 to 1,000,000 and write them to a file named: squares.txt 3.) Here are the function prototypes: void writeRoots(); void writeSquares();
Computers and Technology
1 answer:
svlad2 [7]3 years ago
3 0

Answer:

The csharp program to compute square roots of numbers and write to a file is as follows.

class Program  

{  

static long max = 1000000;  

static void writeRoots()  

{  

StreamWriter writer1 = new StreamWriter("roots.txt");  

double root;  

for (int n=1; n<=max; n++)  

{  

root = Math.Sqrt(n);  

writer1.WriteLine(root);  

}  

}  

static void Main(string[] args)  

{  

writeRoots();  

}  

}

The program to compute squares of numbers and write to a file is as follows.

class Program  

{  

static long max = 1000000;  

static void writeSquares()  

{  

StreamWriter writer2 = new StreamWriter("squares.txt");  

long root;  

for (int n = 1; n <= max; n++)  

{  

root = n*n;  

writer2.WriteLine(root);  

}  

}  

static void Main(string[] args)  

{  

writeSquares();  

}  

}  

Explanation:

1. An integer variable, max, is declared to hold the maximum value to compute square root and square.

2. Inside writeRoots() method, an object of StreamWriter() class is created which takes the name of the file as parameter.

StreamWriter writer1 = new StreamWriter("roots.txt");

3. Inside a for loop, the square roots of numbers from 1 to the value of variable, max, is computed and written to the file, roots.txt.

4. Similarly, inside the method, writeSquares(), an object of StreamWriter() class is created which takes the name of the file as parameter.

StreamWriter writer2 = new StreamWriter("squares.txt");

5. Inside a for loop, the square of numbers from 1 to the value of the variables, max, is computed and written to the file, squares.txt.

6. Both the methods are declared static.

7. Inside main(), the method writeRoots() and writeSquares() are called in their respective programs.

8. Both the programs are written using csharp in visual studio. The program can be tested for any operation on the numbers.

9. If the file by the given name does not exists, StreamWriter creates a new file having the given name and then writes to the file using WriteLine() method.

10. The csharp language is purely object-oriented language and hence all the code is written inside a class.

You might be interested in
Which of these options highlights the need for learning algorithms
LiRa [457]

Answer: D.

Explanation:

7 0
3 years ago
Read 2 more answers
The weight of your car will also affect its_____.
Usimov [2.4K]

Answer: C

Explanation:

4 0
2 years ago
Read 2 more answers
Which of the following attacks is MOST likely the cause when a user attempts to go to a website and notices the URL has changed?
lilavasa [31]

Answer: C) DNS poisoning

Explanation: DNS poisoning or DNS cache poisoning is the type of attacking tendency towards the URL of the computer. These attempt to attack the URL using the spam mails and the user usually end up clicking on the URL provided by the attacker which invokes attack in the computer.

This mechanism takes place in the emails as well as the selected websites which can be accessed by the users easily.These attacks once enter the system seems like the real thing and become prone to many risks .

6 0
3 years ago
Northern Trail Outfitters uses a custom object Invoice to collect customer payment information from an external billing system.
Kobotan [32]

An administrator should ensure this requirement by creating a process builder to set the field.

<h3>What is a billing system?</h3>

A billing system is a complex software that enables service providers' order to cash process (O2C) and sends invoices, tracks, and processes payments for different consumers.

It is the process by which a business bills and invoices customers. Billing systems often include payment software that automates the process of collecting payments, sending out recurring invoices, expense tracking, and invoice tracking.

Learn more about billing system here,

brainly.com/question/14315763

#SPJ1

8 0
2 years ago
For some reason i cant see brainly answers
denis23 [38]

Answer:

Same thing happening to me and several other people. At this point I wonder if there site is having troubles. I tried to email them but even that is not working.

Explanation:.

4 0
3 years ago
Other questions:
  • A custom information field that helps users to find a specific document is called
    8·2 answers
  • You need to perform maintenance on a router and need to temporarily reroute traffic through another office. which would be the b
    6·1 answer
  • Indexed sequential access, an index is more useful when the number of record is
    10·1 answer
  • Explain why Windows and Linux implements multiple locking mechanisms. Describe the circumstances under which they use spinlocks,
    13·1 answer
  • Explain how SEO impacts the way you should interpret search engine results ???
    6·1 answer
  • Let x = ["Red", 2.55,"Green", 3,"Black","false"], then solve the following:
    7·1 answer
  • Question # 4
    5·1 answer
  • Which of the following is not true?A. An organization may express its cybersecurity state through a Current Profile to report re
    10·1 answer
  • Brainliest to right answer.
    10·1 answer
  • Select the incorrect sentence from the options given below. *
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!