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
Brrunno [24]
4 years ago
6

Input 10 integers and display the following:

Computers and Technology
1 answer:
LekaFEV [45]4 years ago
3 0

Answer:

// code in C++

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

   // variables

   int sum_even=0,sum_odd=0,eve_count=0,odd_count=0;

   int largest=INT_MIN;

   int smallest=INT_MAX;

   int n;

   cout<<"Enter 10 Integers:";

   // read 10 Integers

   for(int a=0;a<10;a++)

   {

       cin>>n;

       // find largest

       if(n>largest)

       largest=n;

       // find smallest

       if(n<smallest)

       smallest=n;

       // if input is even

       if(n%2==0)

       {  

           // sum of even

           sum_even+=n;

           // even count

           eve_count++;

       }

       else

       {

           // sum of odd    

          sum_odd+=n;

          // odd count

          odd_count++;

       }

   }

   

   // print sum of even

   cout<<"Sum of all even numbers is: "<<sum_even<<endl;

   // print sum of odd

   cout<<"Sum of all odd numbers is: "<<sum_odd<<endl;

   // print largest

   cout<<"largest Integer is: "<<largest<<endl;

   // print smallest

   cout<<"smallest Integer is: "<<smallest<<endl;

   // print even count

   cout<<"count of even number is: "<<eve_count<<endl;

   // print odd cout

   cout<<"count of odd number is: "<<odd_count<<endl;

return 0;

}

Explanation:

Read an integer from user.If the input is greater that largest then update the  largest.If the input is smaller than smallest then update the smallest.Then check  if input is even then add it to sum_even and increment the eve_count.If the input is odd then add it to sum_odd and increment the odd_count.Repeat this for 10 inputs. Then print sum of all even inputs, sum of all odd inputs, largest among all, smallest among all, count of even inputs and count of odd inputs.

Output:

Enter 10 Integers:1 3 4  2 10 11 12 44 5 20                                                                                

Sum of all even numbers is: 92                                                                                            

Sum of all odd numbers is: 20                                                                                              

largest Integer is: 44                                                                                                    

smallest Integer is: 1                                                                                                    

count of even number is: 6                                                                                                

count of odd number is: 4

You might be interested in
Your program will demonstrate use of arrays, searching an array, using methods, passing parameters by reference, returning value
Contact [7]

woahhhhhhhhhhhhhhhhhh dude

4 0
4 years ago
How is a Creative Commons license different from a regular copyright?
gayaneshka [121]

Answer:

Creative Commons is actually a license that is applied to a work that is protected by copyright. It's not separate from copyright, but instead is a way of easily sharing copyrighted work. ... Copyright confers some pretty heavy duty protections so that others don't use your work without your permission.

Explanation:

8 0
3 years ago
Is hacking always wrong? Creating viruses?
nalin [4]

Answer:

yes

Explanation:

6 0
2 years ago
Read 2 more answers
1. Science is the body of knowledge and methods produced by engineering.
olga nikolaevna [1]
True. Technology changes society
6 0
3 years ago
0010 0000<br> What is the binary decimal
Degger [83]

Answer:

The decimal number is 32 and the Hexidecimal  is 20

5 0
3 years ago
Read 2 more answers
Other questions:
  • Write a function "hailstone"that takes an int "n2"and prints the hailstone sequence. Hailstone Numbers:This sequence takes the n
    15·1 answer
  • Which program has an indexed version of the NIST NSRL of MD5 hashes that can be imported to enhance searching for and eliminatin
    10·1 answer
  • What is renewable energy
    12·1 answer
  • Which software is used for cover letters and resumes
    9·2 answers
  • What is it with the order of operations
    9·1 answer
  • What game is this??????????????????????
    12·1 answer
  • I umm… really need helpp<br> Can someone help me out <br> I’ll even mark u as brainiest !
    12·1 answer
  • Write a program that creates a two-dimensional array initialized with test data. Use any data type you wish. Declare a two-dimen
    9·1 answer
  • Your son is complaining that his smartphone is broken. He tells you that he cannot connect to the internet, nor can he make or r
    13·1 answer
  • Explain briefly how learning how to follow can make a person a good leader
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!