a simple structured program in c++ to calculate average of n items​

Answers

Answer 1

Answer:

#include <iostream>

using namespace std;

int main ()

{

 int n, i;

 float sum = 0.0, average;

 cout << "Enter the number of items:";

 cin >> n;

 float num[n];

 for(i = 0; i < n; ++i)

 {

   cout << "Enter a number: ";

   cin >> num[i];

   sum += num[i];

 }

 average = sum / n;

 cout << "Average = " << average;

 return 0;

}

Explanation:

OK, I let ChatGPT write this one, but it is a proper solution. You can simplify it by not storing each number in an array element. This is because other than adding it to the sum, you don't need these numbers.


Related Questions

I need help with the question below.

import java.util.*;

public class TreeExample2 {

public static void main (String[] argv)
{
// Make instances of a linked-list and a trie.
LinkedList intList = new LinkedList ();
TreeSet intTree = new TreeSet ();

// Number of items in each set.
int collectionSize = 100000;

// How much searching to do.
int searchSize = 1000;

// Generate random data and place same data in each data structure.
int intRange = 1000000;
for (int i=0; i 0)
r_seed = t;
else
r_seed = t + m;
return ( (double) r_seed / (double) m );
}

// U[a,b] generator
public static double uniform (double a, double b)
{
if (b > a)
return ( a + (b-a) * uniform() );
else {
System.out.println ("ERROR in uniform(double,double):a="+a+",b="+b);
return 0;
}
}

// Discrete Uniform random generator - returns an
// integer between a and b
public static long uniform (long a, long b)
{
if (b > a) {
double x = uniform ();
long c = ( a + (long) Math.floor((b-a+1)*x) );
return c;
}
else if (a == b)
return a;
else {
System.out.println ("ERROR: in uniform(long,long):a="+a+",b="+b);
return 0;
}
}

public static int uniform (int a, int b)
{
return (int) uniform ((long) a, (long) b);
}

public static double exponential (double lambda)
{
return (1.0 / lambda) * (-Math.log(1.0 - uniform()));
}

public static double gaussian ()
{
return rand.nextGaussian ();
}


public static double gaussian (double mean, double stdDeviation)
{
double x = gaussian ();
return mean + x * stdDeviation;
}

} // End of class RandTool

Answers

The given code is a Java program that includes a class named TreeExample2 with a main method. It demonstrates the usage of a linked list and a tree set data structure to store and search for elements.

The program begins by creating instances of a linked list (LinkedList) and a tree set (TreeSet). Then, it defines two variables: collectionSize and searchSize. collectionSize represents the number of items to be stored in each data structure, while searchSize determines the number of search operations to be performed.

Next, the program generates random data within the range of intRange (which is set to 1000000) and inserts the same data into both the linked list and the tree set.

The program uses a set of utility methods to generate random numbers and perform various operations. These methods include:

uniform(): Generates a random double between 0 and 1 using a linear congruential generator.

uniform(double a, double b): Generates a random double within the range [a, b).

uniform(long a, long b): Generates a random long within the range [a, b].

uniform(int a, int b): Generates a random integer within the range [a, b].

exponential(double lambda): Generates a random number from an exponential distribution with the specified lambda parameter.

gaussian(): Generates a random number from a standard Gaussian (normal) distribution.

gaussian(double mean, double stdDeviation): Generates a random number from a Gaussian distribution with the specified mean and standard deviation.

Overall, the code serves as an example of using a linked list and a tree set in Java, along with utility methods for generating random numbers from various distributions.

9
Select the correct answer.
What is the purpose of flowcharts?
OA.
О в.
O C.
to depict objects and classes
to show the flow of data between functions
to show the relationships between data entities
O D. to provide a high-level description of code
O E. to represent algorithms graphically
Undo
Next
Edmentum/ Plato

Answers

B. To show the flow of data between functions

When writing technical information to a non-technical audience, you discover that the information appears to be geared more toward an expert audience. Which of the following strategies can help to adapt the writing to meet the needs of your audience?

Answers

When adapting technical information for a non-technical audience, several strategies can be employed to ensure clarity and understanding:

The Strategies

Simplify language: Replace technical jargon and acronyms with plain language that is easily understood by the general audience.

Define terms: If technical terms are necessary, provide clear definitions or explanations to help readers comprehend their meaning.

Use analogies: Relate complex concepts to familiar everyday situations or objects, making it easier for non-experts to grasp the ideas.

Break down complex ideas: Divide complex information into smaller, more manageable sections, and provide step-by-step explanations or examples.

Visual aids: Utilize visuals such as diagrams, charts, or infographics to supplement the text and enhance understanding.

Provide context: Frame technical information within a broader context to help readers understand its relevance and importance.

Test for comprehension: Seek feedback from non-technical individuals to gauge their understanding and make necessary revisions.

By implementing these strategies, you can effectively bridge the gap between technical content and a non-technical audience, facilitating comprehension and engagement.

Read more about technical information here:

https://brainly.com/question/7788080

#SPJ1

Read the Python program below:
1 num1 = int(input())
2
num2 = 10 + num1 * 2
3
print(num2)
4 num1 = 20
5 print(num1)
Question 2
When this program is executed, if the user types 10 on the
keyboard, what will be displayed on the screen as a result of
executing line 5?
A. 10
B. 20
C. 10 and 20
D. There is an error in the program because a variable cannot
hold two values at the same time

Answers

When the program is executed and the user types 10 as input, the program will display the following on the screen as a result of executing line 5:  20 (Option B)

How does this work?

Line 5 print(num1) will print the value stored in the variable num1, which is 20 at that point in the program.

The variable num1 was reassigned the value 20 in line 4, so the updated value of num1 is printed, which is 20. Therefore, the output will be 20.

Learn more about program at:

https://brainly.com/question/23275071

#SPJ1

Select the correct answer from each drop-down menu. Erin is writing an essay about the factors that can lead to mental illness Choose the correct way to complete each sentence. One factor leading to mental illness is Exposure to toxins during © 2023 Edmentum. All rights reserved. which can be caused by the type of closed-head injury that occurs during a car accident. also increases the risk of developing a mental illnesses ​

Answers

A wide variety of mental health conditions—disorders that impact your emotions, thinking, and behavior—are referred to as mental illnesses, sometimes known as mental health disorders.

Thus, Depression, anxiety disorders, schizophrenia, eating disorders, and compulsive behaviors are a few examples of mental illnesses. Many people occasionally experience problems with their mental health.

However, a mental health issue turns into a mental disease when persistent symptoms put you under a lot of stress and impair your capacity to perform daily tasks.

A mental illness can make your life miserable and interfere with regular activities including work, school, and relationships. Most of the time, a combination of medicine and talk therapy helps control symptoms.

Thus, A wide variety of mental health conditions—disorders that impact your emotions, thinking, and behavior—are referred to as mental illnesses, sometimes known as mental health disorders.

Learn more about Mental health, refer to the link:

https://brainly.com/question/31708532

#SPJ1

Type the correct answer in the box. Spell all words correctly.
Once an application is deployed, which phase allows for the implementation of new requirements?
After the deployment of an application, the
phase allows for the implementation of new requirements,
Mpdo
Next
Edmentum/Plato

Answers

Software deployments to a range of computing services, including Amazon EC2, AWS Faregate, AWS Lambda, and your on-premises servers, are automated via the completely managed deployment solution AWS Code Deploy.

Open the Code Deploy console at https://console.aws.amazon.com/codedeploy after logging into the AWS Management Console. Sign in using the same IAM user information or account that you used to access Code Deploy before. Choose Applications after expanding Deploy in the navigation bar.

With the use of the AWS Support API, programmers may generate, manage, and close support issues, as well as operationally manage Trusted Advisor check requests and status. Customers of AWS Support who have a Business or Enterprise support package have access to the AWS Support API.

To learn more about 'Software' refer to

brainly.com/question/15245978

#SPJ1

Type the correct answer in the box. Spell all words correctly.
Based on the given information, in which phase of the SDLC is Leigh involved?
Leigh works in an IT firm. She shows prototypes of software to clients. Leigh is involved in the
Undo
Next
phase of the SDLC.
Edmentum/ Plato

Answers

Leigh works in an it firm. she shows prototypes of software to clients. leigh is involved in the Implementation phase of the sdlc.

A project management model called the system development life cycle outlines the steps needed to take a project from conception to completion. For instance, software development teams use many models of the systems development life cycle, such as the waterfall, spiral, and agile methods.

The planning, system analysis, system design, development, implementation, integration, testing, and operations and maintenance phases of the systems development life cycle are included. When the goal of the system development life cycle is to create software applications, security is essential.

To know more about systems development life cycle (SDLC) , visit:

brainly.com/question/15696694

#SPJ1

PLEASE I NEED HELP ASAP!! WILL MARK BRAINILEST

Answers

Some examples of HTML tags you might observe in the source code of a web page:

<html>: Represents the root element of an HTML document.<head>: Contains metadata and other non-visible information about the web page.<title>: Specifies the title of the web page that appears in the browser's title bar or tab.What is the act of using the tags?

The tag serves as the fundamental element for an HTML file. This tag envelops all the remaining components of the webpage.

The element holds important information about the webpage such as metadata and other details that are not visible to the user. One of the components found in web pages is the <title> tag, which indicates the webpage's title.

The <title> element identifies the webpage's title. The information displayed in the title bar or tab of a browser is commonly utilized to offer a concise summary of the webpage's content.

Learn more about Web Page from

https://brainly.com/question/28431103

#SPJ1

Creating a Web Page Using HTML: Tutorial

An HTML File

This activity will help you meet these educational goals:

8 of 25

Save &

• Content Standards-You will perform an Investigation, in which you will make observations and communicate your results in written form. Inquiry-You will perform an Investigation, in which you will make observations and communicate your results in written form.

⚫ 21st Century Skills-You will use critical thinking and problem solving skills.

Directions

Read the instructions for this self-checked activity. Type in your response to each question, and check your answers. At the end of the activity, write a brief evaluation of your work.

Activity

Visit the About Us page of Edmentum's web site. Once the web page loads, view the source HTML file by right-clicking on the page and choosing View Source (in Internet Explorer) or View Page Source (in Firefox or Chrome). If you use Safari, you have to click on Develop | Show Page Source. (If Develop is not visible, go to Preferences and tick Show Develop in the Advanced menu bar.)

Part A

Observe the HTML code. You will see many instances of text enclosed in angle brackets . These instances of text are HTML tags. List some of the HTML tags you see.


Investigate the different types of compact disks

Answers

Answer: the most common ones include CD-Audio, CD-ROM, CD-R, CD-RW, and CD-DA.

Explanation:

Compact Discs (CDs) are optical storage media that have been widely used for audio, data, and video storage. While there are several types of CDs, the most common ones include CD-Audio, CD-ROM, CD-R, CD-RW, and CD-DA.

1. CD-Audio: It is also known as a music CD or audio CD, CD-Audio is primarily used for storing and playing back audio recordings. It can hold up to 74 minutes (or 80 minutes with overburning) of uncompressed audio in the Red Book format. CD-Audio discs can be played on standalone CD players and most computer CD/DVD drives.

2. CD-ROM: CD-ROM stands for Compact Disc Read-Only Memory. These discs contain data that can only be read and not written or modified. CD-ROMs are widely used for distributing software, games, multimedia applications, and other types of data. They can store up to 700 MB (or 80 minutes) of data.

3. CD-R: CD-R (Compact Disc-Recordable) discs are blank discs that can be recorded once using a CD burner or writer. Once the data is written, it becomes permanent and cannot be erased or modified. CD-Rs are commonly used for creating backups, storing music compilations, and archiving data. They also have a capacity of 700 MB (or 80 minutes).

4. CD-RW: CD-RW (Compact Disc-ReWritable) discs are similar to CD-Rs but with the added ability to be erased and rewritten multiple times. This rewritable feature makes CD-RWs suitable for tasks that require frequent data changes or updates. The capacity of CD-RW discs is the same as CD-Rs, i.e., 700 MB (or 80 minutes).

5. CD-DA: CD-DA (Compact Disc Digital Audio) is another term for CD-Audio, indicating that the disc contains uncompressed audio in the standard Red Book format. CD-DA discs can be played on CD players and CD-ROM drives that support audio playback.

ed 4. As a network administrator of Wheeling Communications, you must ensure that the switches used in the organization are secured and there is trusted access to the entire network. To maintain this security standard, you have decided to disable all the unused physical and virtual ports on your Huawei switches. Which one of the following commands will you use to bring your plan to action? a. shutdown b. switchport port-security c. port-security d. disable

Answers

To disable unused physical and virtual ports on Huawei switches, the command you would use is " shutdown"

How doe this work?

The "shutdown" command is used to administratively disable a specific port on a switch.

By issuing this command on the unused ports, you effectively disable those ports, preventing any network traffic from passing through them.

This helps enhance security by closing off access to unused ports, reducing the potential attack surface and unauthorized access to the network.

Therefore, the correct command in this scenario would be "shutdown."

Learn more about virtual ports:
https://brainly.com/question/29848607
#SPJ1

True or False: Only CSS has online documentation because it is a more complex language than HTML. O True False​

Answers

Answer:

False

Explanation:

Both CSS (Cascading Style Sheets) and HTML (Hypertext Markup Language) have online documentation. CSS and HTML are separate languages with different purposes. HTML is used for structuring and presenting content on the web, while CSS is used for styling and formatting the appearance of that content.

Both languages have their own specifications and documentation available online. HTML documentation provides information about the various elements, attributes, and their usage, while CSS documentation covers properties, selectors, and how to apply styles to HTML elements.

Therefore, it is incorrect to say that only CSS has online documentation. Both CSS and HTML have extensive documentation available for reference.

What most directly led the U.S. government to publish the coordinated framework of the regulation of biotechnology in 1986

A the discovery of dna by Franklin, Watson, crick

B the outdated regulation for generic manipulation

C the lack of any regulations for biotech activities

D the desire for a new agency to oversee biotech

Answers

The thing that most directly led the U.S. government to publish the coordinated framework of the regulation of biotechnology in 1986 was C. The lack of any regulations for biotech activities

How did this happen?

The United States Due to the absence of regulations governing biotech activities, the government released the Coordinated Framework for the Regulation of Biotechnology in 1986.

There was increasing worry about the possible hazards and unknowns related to developing biotechnologies at that point in time. A lack of clear directives and monitoring necessitated the implementation of a synchronized regulatory framework that could effectively tackle the distinctive hurdles posed by biotechnology.

The objective of the framework was to create a well-defined regulatory route and offer instructions for evaluating the safety and environmental consequence of biotechnology products and actions.

Read more about biotech here:

https://brainly.com/question/29703343

#SPJ1

The purpose of post market surveillance is to make regulation more effective and recalls easier

True or false

Answers

Answer:True

Explanation:

The purpose of post-market surveillance is to make regulation more effective and recalls easier. Post-market surveillance plays a crucial role in monitoring the safety and effectiveness of products after they have been approved and made available in the market. It helps regulatory authorities identify and address any issues or risks associated with the product's use, leading to more effective regulation. Additionally, by monitoring products in the market, post-market surveillance facilitates the identification of potential problems, which can make recalls easier if necessary to protect public health and safety.

Other Questions
Julie's company produces knee warmers according to the following production function q= (K-8) L(Q9) Assuming that the unit cost of capital (r) and the unit wage (w) are both equal to 1, Julie's demand for inputs are L = q2 and K = q2.(Q10) Julie's total long run cost function is C(q) = 8+q2.(Q11) The long run price in this market is p = 4.(Q12) Each firm in the long run will produce q = 2.(Q13) the number of firms in the market in the long run is 16. given the following styles, what size will the text of the label be? .root { -fx- font-size: 12pt; } .label { -fx- font-size: 18pt; } Determine if the series converges absolutely, converges conditionally, or diverges: a) sigma_n=2^infinity (-1)^n ln (n + 2)/ln (2n) (b) sigma_n=1^infinity (-1)^n 1/Squareroot n (c) sigma_n=1^infinity (-1)^n (1/2)^n Use the Alternating Series Approximation Theorem to find N so that sigma_n=1^N (-1)^n - 1/n^3 gives the sum of the series sigma_n=1^infinity (-1)^n-1/n^3 with less than 000001 error A 1:200 scale blueprint of an archaeological dig site has an area of 100 cm2. The area (in units of m2) of the actual dig site is: (Answer to zero decimal places) Your Answer: Answer Should the federal government become involved in subsidizing earthquake insurance? 4. If we could improve our ability to forecast earthquakes, how would this affect the cost of earthquake insurance? True or false:The problem insurance companies have in deciding on premiums for earthquake insurance is major insurance companies know very little about faults and earthquakes. Relational Algebra Use the following relations from the Research University Schema to answer the problems belc Relations: Professor(SSN ,Rank, Specialty) GraduateStudent(SN, DegreeProgram, AdvisorSSN, DepartmentNumber) Project(Number, StartDate, EndDate, Budget, SponsorOrganizationName) Department (Number, Name, Abbreviation, MainOffice, ChairmanSSN) WorksFor(ProfessorSSN, DepartmentNumber, TimePercentage) WorksOn(GraduateStudentSSN, ProjectNumber, SupervisingProfessorSSN) Foreign Keys: Professor(SSN)Person(SSN) GraduateStudent (SSN)Person(SSN) GraduateStudent(AdvisorSSN) GraduateStudent(SSN) Department ( ChairmanSSN ) Professor (SSN) WorksFor(ProfessorSSN) Professor(SSN) WorksFor(DepartmentNumber) Department(Number) WorksOn(GraduateStudentSSN) GraduateStudent(SSN) WorksOn(SupervisingProfessorSSN) Professor(SSN) d) Retrieve the Name and Rank of all Professors who supervise graduate students on projects with Budgets greater than 1 million dollars. e) Retrieve the Name and Degree Program of all Graduate Students who work on Project 34132 and do not work on Project 38475 Question: The table below indicates the units of labor in each country needed to produce a unit of output for the corresponding good: Good X Good Y Based on ... 5. If your t-test value is t=1.45 and the critical value is CV=5.66, your data is: A.significant B.different not significantly different.7. Why is the standard error of the mean used for the t-test and not the standard deviation?a.because information about the sample is not known and using the SEM might create a biased resultb.because information about the population is known and using the SD might create a unbiased resultc.because information about the population is not known and using the SD might create a biased resultd.because information about the sample is not known and using the SD might create an unbiased result The supply curve of an individual producer is based on the expected price in the market. True or False? Which statement best describes the results of this study?a. Trade-offs between seed size and seed number existed in both the control and the fertilizer groups, and these trade-offs were of roughly equal magnitude.b. Trade-offs between seed size and seed number existed in both the control and the fertilizer groups, but these trade-offs were much larger in the fertilizer group.c. A trade-off between seed size and seed number existed in the control group but not in the fertilizer group.d. A trade-off between seed size and seed number existed in the fertilizer group but not in the control group. Consider the points which satisfy the equation y = x3 + ax + b mod p where a = 2,b= 1, and p = 7. - This curve contains the point P = (0,1). Enter a comma separated list of points (x, y) consisting of all multiples of P in the elliptic curve group with parameters a = 2, b = 1, and p = 7. (Do not try to enter O, the point at infinity, even though it is a multiple of P.) - What is the cardinality of the subgroup generated by P? President John F. Kennedy established this organization in 1961 to promote humanitarian efforts around the world. U.S. citizens can volunteer to participate in its programs.Which non-governmental organization does this statement describe? United StatesMexicoCanada Agreement United Nations Peace Corps North Atlantic Treaty Organization ed. What is the population of interest here? a.All students who are satisfied with the amount of after-school activities that are offered. b.All students who attend the school. c.All students who participated in the poll. d.All students who are not satisfied with the amount of after-school activities that are offered. Convert the rectangular coordinates (-1, -3) into polar form. Express the angle using radians in terms of over the interval 0 0 < 27, with a positive value of r. Convert the complex number -3 + 2i into polar form. Express the angle using degrees over the interval 0 < 0 < 360. You may round the argument to the nearest tenth of a degree (if necessary), but you must express your modulus in its exact form. COS + i sin Convert the complex number -3 - 3i into polar form. Express the angle using radians in terms of 7 over the interval 0 0 < 2TT. COS +i sin What is a solution for a globes view Governments are said to find it very difficult to influence the international business environment compared to multinationals that sometimes have sales greater than a governments Gross National Product.How fair is it to say that governments have little influence on the international environment when compared to others including multinationals and what can they do individually or in concert to exercise their desired influence? premenstrual edema may be due to enhanced reabsorption of sodium chloride. T/F? The specificity of a diagnostic test is the probability that an individual does not have the disease being tested for when they have tested negative. Suppose that a COVID-19 test is given to 100 people, 26 of which have the disease and 74 of which do not. Of those who have the disease, 23 test positive and 3 test negative; of the 74 who do not have the disease, 6 test positive and 68 test negative. Round your answer to three decimal places. What is the specificity of this test? Isaac used to work as a welder, but that came to an end five years ago when a poodly secured learn from a crushed his arm. He has been unable to work ever since. Fortunately, he had purchased an individual disability insurance policy to Income. When he first became disabled, he received benefits of $3,000 a month from that policy, Now, he receives bonates of $3,300&mom works w What rider did Issac most likely add to his policy when he purchased t O A cost of living adjustment rider. Along-term care insurance rider O A future purchase option rider O An accidental death and dismemberment rider. Curtis invests $5000 in an account that compounds interest monthly and earns 8 %. How long will it take for his money to double? HINT While evaluating the log expression, make sure you round to at least FIVE decimal places. Round your FINAL answer to 2 decimal places It takes____ years for Curtis's money to double