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]
4 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]4 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
Bruce realizes he's getting a cramp in his neck after texting with his buddy for several minutes. he puts the phone down and tak
Arlecino [84]

Answer:Tech Neck

Explanation:

Tech Neck is when you are looking down to a phone for too long and you get a cramp in your neck

6 0
1 year ago
What are two ways to access the options for scaling and page orientation? click the home tab, then click alignment, or click the
inessss [21]

The answer is Click the file tab, then click print, or click the page layout tab.

Sometimes, you may want certain pages or sections to have a different orientation (vertical or landscape layout) from the rest of the content inside. To achieve this, you could either go to the file tab then click print or click the page layout tab and click on the drop down arrow to select the options available.  

4 0
3 years ago
Give examples of two IP addresses (that are 100 IP addresses away from each other but the last octet is not greater than .150) t
aniked [119]

Answer:

Explanation:

255.255.255.0 is the Subnet for the network DCI, it makes it a workable network to allow 254 users.

It as an IP address exclusion range between 192.168.42.100 - 192.168.42.110, this makes it overall accessible through X. X.X.1 - 99 and X. X. X - 110 - 252.From this, 90 address are being used, so 2 addresses can be picked as 192.168.42.6 and 192.168.42.106. These are 100 addresses apart, and the final Ocet is not more than 150.

3 0
3 years ago
Select the correct answer.
riadik2000 [5.3K]

Answer: B- Clip art

Explanation:

5 0
3 years ago
Conformity is the acceptance of culturally approved goals and the means for achieving these goals.
docker41 [41]

Answer:

The following statement is "True".

Explanation:

Conformity acceptance word divided into two parts that are Conformity and acceptance. Conformity stands for change in behavioral change or conviction. Or considered the stress of the party. and the acceptance stands for thinking and trusting across community standards.  behaving and believing along social lines.

In other words we can say that achieving cultural goals via channels that are culturally approved and utilizing traditionally unorthodox methods to achieve cultural goals.

6 0
3 years ago
Read 2 more answers
Other questions:
  • Mutual authentication for multiple services is also known as _______.
    12·1 answer
  • Computer ________ involves identifying, extracting, preserving, and documenting computer evidence. a. inoculation b. forensics c
    8·1 answer
  • Which of the following is NOT true about high-level programming<br> languages?
    9·2 answers
  • Um can anyone who is really into science and physics answer this question
    7·1 answer
  • Individuals who require better speed and performance for graphics-intensive applications (e.g., video editing, gaming, etc.) pre
    8·1 answer
  • Although you are not a full administrator, you are asked to manage a protected document, allowing customized access to any inter
    7·1 answer
  • A corporation needs an operating system that allows the various teams in its office to network and collaborate on projects. Whic
    13·2 answers
  • WILL MARK BRAINILY!!
    9·2 answers
  • Any song recommendations, pls dont say 6ix9ine or lil pump
    5·2 answers
  • What is e banking effects
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!