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
Gala2k [10]
3 years ago
8

Write a function that asks the user to enter integer odd values and prints out on the screen their count, sum, max, min, and ave

rage. The user keep entering odd values till he enters the first even value.
Computers and Technology
1 answer:
vodomira [7]3 years ago
8 0

Answer:

#include<iostream>

using namespace std;

//main function

int main(){

   //initialization

  int counts_Values=0, sum_all_Values=0;

  int max_Value,min_Value;

  float averge_Value;

  int num1;

  //display

   cout<<"Enter the odd values; ";

   cin>>num1;  //store the number

   max_Value=num1;

   min_Value=num1;

   //while loop for run continuously until odd numbers

   while(num1%2 != 0){

       counts_Values++;  //increment count

       sum_all_Values = sum_all_Values + num1;  //calculate sum

       //calculate the maximum value

       if(num1>max_Value){

           max_Value=num1;

       }

       //calculate the minimum value

       if(num1<min_Value){

           min_Value=num1;

       }

       cout<<"Enter the odd values; ";

       cin>>num1;

   }

   //starting value is even, then store average to zero

   if(counts_Values == 0){

       averge_Value=0;

   }else{

       averge_Value = float(sum_all_Values)/counts_Values;

   }

   //display the result

   cout<<"The count is:"<<counts_Values<<endl;

   cout<<"The sum is:"<<sum_all_Values<<endl;

   cout<<"The Max value is:"<<max_Value<<endl;

   cout<<"The Min value is:"<<min_Value<<endl;

    cout<<"The Average value is:"<<averge_Value<<endl;

   return 0;

}

Explanation:

Include the libraries iostream for using the input/output instruction.

Create the main function and declare the variables.

Print the message on the screen using cout instruction and then store the input enter by the user in the variable using the cin instruction.

then, check the number is even using the if-else statement.

if the number is even, then store zero value stored in the max and min value.

otherwise, store that number in min and max value.

take the while loop with a condition, num1%2 != 0 this condition check the number is not even. if the condition true execute the loop other terminate the loop.

After that, increment the count by 1 and take the sum of value.

then, check for maximum if a new number is greater than the number stored in the max_Value then update the max_Value.

same for min value but the condition will change. Check for the minimum if the new number is less than the number store in the min_Value then update the min_Value.

then, again ask the value from the user.

The above process continues again and again until the user does not enter the even value. if the user enters the even value, the loop terminates and then program checks the count value is zero. if zero then the average is zero other calculate the average.

the above check is used to remove the infinite value. because if we divided the sum with zero it becomes infinite.

and finally, display the output on the screen.

You might be interested in
Difference between softcopy and hardcopy​
Rashid [163]

A hard copy is the digital file, stored in a device and was printed out. A soft copy is the electronic version NOT PRINTED. It is showcased digitally (through a phone, computer, flash drive etc)

3 0
3 years ago
Read 2 more answers
How to know if somebody else is listening my conversations by cellphone?
weeeeeb [17]
I dont think it would be possible for someone to listen to your calls im pretty sure only the police could if they provide a sign warrent by a judge to the phone company
4 0
3 years ago
Which data type stores a single letter?
Irina-Kira [14]

Answer:

c

Explanation:

4 0
3 years ago
What is the task included in the information systems manager?​
kobusy [5.1K]

Answer:

research and install new systems and networks. implement technology, directing the work of systems and business analysts, developers, support specialists and other computer-related workers. evaluate user needs and system functionality, ensuring that IT facilities meet these needs.

Explanation:

5 0
3 years ago
The relational model describes data using a standard tabular format; all data elements are placed in three-dimensional tables ca
frutty [35]

Answer:

False

Explanation:

Relational Database are only two dimensional (not three dimensional).

Note: Relations are two dimensional tables in relations databases.

8 0
3 years ago
Other questions:
  • A proactive computer professional will _____. have a neutral outlook toward technology underestimate the impact of technology an
    13·2 answers
  • ________ errors may indicate that an attacker is trying to send invalid data to the server. 404 303 500 512
    11·1 answer
  • An empty frame used to reserve space for a picture to be inserted at a later time is know as what
    6·1 answer
  • Help me out here pleaseeeee
    9·2 answers
  • Assignment 4: Evens and Odds
    9·1 answer
  • What is the duty of WHH? (white hat hackers)<br><br><br>ANY WHH HERE?<br>​
    8·1 answer
  • Doctrine Creative is a video production company with its own file server within its business office. The company needs to be abl
    8·2 answers
  • How does a fully integrated Data and Analytics Platform enable organizations to convert data into consumable information and ins
    15·1 answer
  • What are the two protocols used most often with iot devices? (select two. )
    10·1 answer
  • Which of these could you use to change data into information?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!