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
IRINA_888 [86]
3 years ago
13

Write a C++ program to read N numbers. Find sum, product, and average of N numbers

Computers and Technology
1 answer:
netineya [11]3 years ago
3 0

Answer:

// here is code in c++

// headers

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

   // variables

   int n,num;

   double sum=0, avg;

   long long int prod=1;

   cout<<"Enter value of N:";

   // read value of N

   cin>>n;

   cout<<"enter "<<n<<" numbers:";

   // read the N numbers

   for(int x=0;x<n-1)

   {

    cin>> num;

    // calculate sum of all

    sum=sum+num;

    calculate product of all

    prod=prod*num;

   }

   // print sum

   cout<<"sum of all "<<n<<" numbers is: "<<sum<<endl;

   // print product

   cout<<"product of all numbers is : "<<prod<<endl;

   print average

   cout<<"average of all "<<n<<" numbers is: "<<sum/n<<endl;

return 0;

}

Explanation:

Read the value of n from user.Then ask user to enter n numbers. Then calculate sum of all entered number and their product.After this calculate the average of entered number by dividing sum with n.Print sum, product and average of n numbers.

Output:

enter value of N:6

enter 6 numbers:1 2 3 4 5 6

sum of all 6 numbers is: 15

product of all numbers is : 120

average of all 6 numbers is: 2.5

You might be interested in
Trish has bought a new computer that she plans to start working on after a week. Since Trish has not used computers in the past,
kotegsom [21]
Hello, I am charlespierce576! I believe I might have the answer! Simple policies such as turning of off devices not in use. Also unplugging devices during a storm.
4 0
4 years ago
If you receive an increase in pay, how will that affect your payroll deductions?
spin [16.1K]
No it will actually help it
3 0
4 years ago
Which of the following do nylon and Kevlar fibers have in common?
asambeis [7]

Answer:

Kevlar. Kevlar is similar in structure to nylon-6,6 except that instead of the amide links joining chains of carbon atoms together, they join benzene rings. The two monomers are benzene-1,4-dicarboxylic acid and 1,4-diaminobenzene.

Explanation:

3 0
2 years ago
Copy the skeleton of code below into your answer. Then in the space indicated, add your own code to prompt the user for two numb
ahrayia [7]

Answer:

import java.util.*;

public class Main

{

public static void main(String[] args) {

    Scanner input = new Scanner(System.in);

   

 System.out.print("Enter the first: ");

 int first = input.nextInt();

 System.out.print("Enter the second: ");

 int second = input.nextInt();

 input.nextLine();

 System.out.print("Enter your name: ");

 String name = input.nextLine();

 

 int difference = Math.abs(second - first);

 

 System.out.println(name + ", the difference is " + difference);

}

}

Explanation:

*The code is in Java.

Create a Scanner object to get input from the user

Ask the user to enter the first, second, and name

Calculate the difference, subtract the second from the first and then get the absolute value of the result by using Math.abs() method

Print the name and the difference as in required format

7 0
3 years ago
Which of the following should you do if you are exhibiting your photographs?
Naddika [18.5K]

I would go with option a

hope that helped

3 0
4 years ago
Other questions:
  • What two images did you have to add to the wds server to handle the windows installation?
    7·1 answer
  • Briefly describe "SoftwareEngineering Framework". Do provide examples and diagrams wherenecessary.
    15·1 answer
  • Powerpoint assumes that the first slide in a new presentation is the
    10·1 answer
  • A _____ is a member function that is automatically called when a class object is created.
    13·1 answer
  • A packet analyzer is a program that can enable a hacker to do all of the following EXCEPT ________. Select one: A. assume your i
    6·1 answer
  • Charlie does not think he will be able to finish his project by the deadline at this point in the decision making progress to so
    13·1 answer
  • Mavis is considering signing up for a hosted enterprise software solution for her small business. She recognizes that an advanta
    15·1 answer
  • Who invented the first mechanical computer? in what year was it invented?.
    11·1 answer
  • I have a problem. I can't cycle between game packs on my strike pack, I've watched so many vids I'm on Xböx and I'm holding the
    13·1 answer
  • A bitmap image is provided in two different resolutions. Image 1 has a resolution of 1500 x 1225. Image 2 has a resolution of 50
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!