Write a program that continues to read positive integer values until user enters a negative value. The program should print average of entered values, maximum value and minimum value

Answers

Answer 1

Answer:

// here is code in C++.

#include <bits/stdc++.h>

using namespace std;

int main()

{

// variable

   int n;

   int mi=INT_MAX;

   int mx=INT_MIN;

   double avg;

   int count=0;

   double sum=0;

   cout<<"enter a positive integer(Negative number to stop):";

   // read the input first time

   cin>>n;

   // read the input until user enter a negative number

   while(n>=0)

   {

   // calculate minimum

       if(n<mi)

       mi=n;

       // calculate maximum

       if(n>mx)

       mx=n;

       // count of entered numbers

       count++;

       // total sum of all number

       sum=sum+n;

       cout<<"enter a positive integer(Negative number to stop):";

       // read the input again

       cin>>n;

   }

   // calculate the average

   avg=sum/count;

   // print the average

   cout<<"average of "<<count<<" number is:"<<avg<<endl;

   // print the maximum

   cout<<"maximum of all number is:"<<mx<<endl;

   // print the minimum

   cout<<"minimum of all number is:"<<mi<<endl;

return 0;

}

Explanation:

Declare and initialize "mi" with maximum integer value.Similarly "mx" with minimum integer value.Read user input until user enter a negative number.Add all the number to variable "sum" and keep count of positive number entered with "count".When user enter a negative number then it will stop taking input and calculate average of all number by dividing sum with count. Also it will check for each and find the maximum and minimum among the all input.

Output:

enter a positive integer(Negative number to stop):23

enter a positive integer(Negative number to stop):10

enter a positive integer(Negative number to stop):34

enter a positive integer(Negative number to stop):22

enter a positive integer(Negative number to stop):5

enter a positive integer(Negative number to stop):-2

average of 5 number is:18.8

maximum of all number is:34

minimum of all number is:5


Related Questions

. If the sub-expression on the left of the __________ logical operator is true, the right

sub-expression is not checked.

Answers

Answer: "║"(OR) logical operator

Explanation:   "ll" logical is used for defining the OR  logical condition.This condition returns a value of true or false according to given expression.This expression can work on the Boolean variables only.

In this operator if any argument turn out to be true , the value returned is true otherwise the answer returned will be false.It also features that if the left side of this operator is true then the right sub-part of it's not evaluated as it becomes true overall.

Example of expression->  x ║ y ;

What is ‘White-Box’ testing?

Answers

Answer:

 The white box testing is the method in which it basically test the internal structure and working application in the software testing.

In the white box testing the programming skills are require for designing the various test cases.

White box testing is also known as open box testing and it require the specific knowledge of the programming language for examine the particular software testing output.

Answer:

    The White Box test is a software test in which the developer has access to the source code, knowing the internal structure of the product. Being analyzed and allowing the choice of specific parts of a component to be evaluated, allowing a precise search of the behavior of the structure.

    The white box test levels are Unit Tests and Static Test.

Prove the following theorems using truth table (a) X + XY = X (b) X + YZ = (X + Y)(X + Z)

Answers

Answer:

I attached you the answer in the picture

Explanation:

First, let's see the relationship between the logic gates and truth tables:

The operation of logic gates in relation to one another may be represented and analyzed using a branch of mathematics called Boolean Algebra which, like the common algebra, deals with manipulation of expressions to solve or simplify equations. Expressions used in Boolean Algebra are called, well, Boolean expressions.

AND Gate:

The AND gate is a logic gate that gives an output of '1' only when all of its inputs are '1'.  Thus, its output is '0' whenever at least one of its inputs is '0'. Mathematically, A∧B = A · B.

OR Gate:

The OR gate is a logic gate that gives an output of '0' only when all of its inputs are '0'. Thus, its output is '1' whenever at least one of its inputs is '1'. Mathematically, A∨B = A + B.

Having this in mind, we just need to use basic Mathematical Logic operations

Other Questions
who led the famous "March to the Sea" if a clocks second hand is 7 in. long , how many feet does it travel in 24 hr? how many miles does it travel? Raoul decided to ask a hypnotherapist to help him deal with difficult childhood issues. What Raoul doesn't realize is that, if the hypnotherapist asks leading questions, the resulting memories can be inaccurate because of: What is White-Box testing? . If the sub-expression on the left of the __________ logical operator is true, the rightsub-expression is not checked. c. What is the relationship between a + b and b + a?d. What is the relationship between a - b and b - a? How Do You Classify In Science How many cubic yards of soil are needed to fill a planter that is 20 feet long by 3 feet wide by 4 feet tall Solve m + 8m = -3 by completing the square.(Use a comma to separate multiple values.)What the answer for this? Melissa is doing a study in which lacrosse players are interviewed about their role on the team and perceived capabilities for playing in Saturdays game. Melissa seems to be assessing the ____ of the lacrosse players. When the theme of a short story is given directlyA. the author states his message clearly and explicitly.B. the author uses indirect methods to deliver his messageC. the author teaches us a valuable life lesson One oak tree cell with 14 chromosomes undergoes meiosis. How many cells will result from this process, and what is the chromosome number in each cell? Which statement about the product is true? 4.56 x 4.5 repeating Find the point on the sphere left parenthesis x minus 4 right parenthesis squared(x4)2 plus+y squared 2 plus+left parenthesis z plus 6 right parenthesis squared(z+6)2 equals=44 nearest to a. the xy-plane. b. the point left parenthesis 7 comma 0 comma negative 6 right parenthesis(7,0,6). Discribe a senario where presentation software might be used in a physician's office practice. 1. Las Ramblas es un bulevar muy famoso en Madrid. cierto falso 2. Hay muchos cafs en Las Ramblas. cierto falso 3. Las Ramblas es un sitio muy popular para los turistas y los residentes de Barcelona. cierto falso 4. Las Ramblas tiene cafs, restaurantes y kioscos. cierto falso 5. Hay una estatua de Cristbal Coln en la Plaa Catalunya. cierto falso 6. El bulevar comienza (begins) en La Rambla de Canaletes y termina (ends) cerca del mar. cierto falso You're an entrepreneur and had a great idea to sell shoes that have springs installed in them to make walking easier. However, the development costs were so high that the shoes are priced 15 times higher than shoes without springs. As a result, many of the shoes have gone unsold. What possible event could eliminate the disequilibrium in the market for shoes?A. A study reveals that shoes with a spring can increase the chance of a broken leg.B. There is an increase in income and "spring shoes" are a normal good.C. There is an increase in income and "spring shoes" are an inferior good.D. There is a decrease in the price of rubber, which is an input in the production of shoes.B. There is an increase in income and "spring shoes" are a normal good. a controlled experiment you could perform to determine whether ants are more attracted to butter or honey Noah is running a portion of a marathon at a constant speed of 6 mph. Complete the table to predict how long it would take him to run different distances at that speed and how far he would run in different time intervals. Time in hours Miles traveled at 6mph1. 1/21 1/3 1 1/2 9 4 1/2 A kangaroo can jump over an object 2.46 m high. (a) Calculate its vertical speed (in m/s) when it leaves the ground.m/s(b) How long (in s) is it in the air?