answer.
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
lesantik [10]
2 years ago
13

9.18 LAB: Even/odd values in a vector Write a program that reads a list of integers, and outputs whether the list contains all e

ven numbers, odd numbers, or neither. The input begins with an integer indicating the number of integers that follow. Ex: If the input is 5 2 4 6 8 10, the output is: all even Ex: If the input is 5 1 3 5 7 9, the output is: all odd Ex: If the input is 5 1 2 3 4 5, the output is: not even or odd Your program must define and call the following two functions. IsVectorEven returns true if all integers in the array are even and false otherwise. IsVectorOdd returns true if all integers in the array are odd and false otherwise. bool IsVectorEven(vector myVec) bool IsVectorOdd(vector myVec)
Computers and Technology
2 answers:
lilavasa [31]2 years ago
8 0

Answer:

This program is written in C++. The explanation of code is given below in explanation section.

Explanation:

#include <algorithm>

#include <functional>

#include <iostream>

#include <vector>

using namespace std;

//function to check vector element is even or not  

bool IsEven(int n) {

   return (n % 2) == 0;

}

//function to check vector element is odd or not

bool IsOdd(int n)

{

   if (n%2!=0)// detection of odd value

   {

       return 1;

   }

}

bool IsVectorEven(vector<int> vect)// check even number in vector

{

   auto countEven = count_if(vect.begin(), vect.end(), IsEven);//count total even numbers in vector

   int size= vect.size();//count total number in vector/check vector size  

   

   if(countEven==size)//all counted even number to size of vector

   {  

       cout<<"\nAll even";//display the message

       //return 1;

   }

   else

   {

       cout<<"\nnot even or odd";//else display the message

      // return 0;

   }

}

bool IsVectorOdd(vector<int> vect)//check odd vector

{

   auto countOdd = count_if(vect.begin(), vect.end(), IsOdd);// count total odd number in vector

   int size= vect.size();// count total number in vector

   

   if(countOdd==size)// if vector size is equal to vector counted odd number

   {  

       cout<<"\nAll odd";// then vector has all odd number/elements

       //return 1;

   }

   else

   {

       cout<<"\nnot even or odd";//else has odd and even numbers

       //return 0;

   }

}

int main()

{

   vector<int> vec{ 4, 2, 4, 6, 8, 10};//declaration of a vector

   

   IsVectorEven(vec);//check even number in vector  

   IsVectorOdd(vec);//check odd number in vector.  

   

   

   

   

   

}

                                           

____ [38]2 years ago
4 0

Answer:

integers=[]

while True:

      number=int(input())

      if number<0:

       break

      integers.append(number)  

print("",min(integers))

print("",max(integers))

Explanation:

You might be interested in
Write code which takes a user input of a String and an integer. The code should print each letter of the String the number of ti
il63 [147K]

import java.util.*;

public class myClass {

public static void main(String args[]) {

Scanner scan = new Scanner(System.in);

System.out.print("Input a String: ");

String str = scan.nextLine();

System.out.print("Input an integer: ");

int num = scan.nextInt();

for(int i=str.length()-1; i>=0; i--) {

for(int j=0; j<num; j++) {

System.out.print(str.charAt(i));

}

}

}

}

8 0
2 years ago
Match the careers with the career clusters.
creativ13 [48]
<h2>Answer and Explanation:</h2>

The picture shows the right careers with their respective career clusters.

4 0
2 years ago
Read 2 more answers
Temperature Class Write a Temperature class that will hold a temperature in Fahrenheit and provide methods to get the temperatur
posledela

Answer:

Explanation:

   public class Temperature

   {

       double ftemp;

       public int Constructor(double fahrenheit)

       {

           ftemp = fahrenheit;

          return Convert.ToInt32(ftemp);

       }

       public void setFahrenheit(double fahrenheit)

       {

           ftemp = fahrenheit;

       }

       public void getFahrenheit()

       {

           ftemp = Constructor(ftemp);

       }

       public void getCelcius()

       {

           ftemp = (ftemp - 32) * 5 / 9;

       }

       public void getKelvin()

       {

           ftemp = (ftemp - 32) * 5 / 9 + 273.15;

       }

   }

8 0
2 years ago
American company Software Unlimited is planning to expand its operations to the Bangor Republic where the group is the primary u
FinnZ [79.3K]

Answer:E. Employees will achieve close cooperation with others.

Explanation: Employees will close cooperation with others as a result of the expansion of the company to the Bangor Republic where the group is the primary unit of social organisation, When a company expands to new locations it boosts employment morale and corporation as they find it as a form of expansion and overall good of the employees and their employer, most of expand as a result of favourable economic climates.

7 0
2 years ago
Liza is making a presentation on the sales revenue of her surfboard company’s most popular surfboard models. She wants to emphas
Kazeer [188]
Answer:  
Liza is making a presentation on the sales revenue of her surfboard company’s most popular surfboard models. She wants to emphasize the model names as they appear one by one on the presentation slide. She also wants to depict the sales data for each model. "Goal seek" options can she use to achieve these goals.
6 0
2 years ago
Read 2 more answers
Other questions:
  • A chemical found in the synaptic vesicles , which , when released . has an effect on the next cell is called a?
    10·1 answer
  • Exercise 6.3 consider memory storage of a 32-bit word stored at memory word 42 in a byte-addressable memory. (a) what is the byt
    14·1 answer
  • How efficient would a 6-bit code be in asynchronous transmission if it had 1 parity bit, 1 start bit, and 2 stop bits?
    5·1 answer
  • Distinguish multiple inheritance and selective inheritance in oo concepts.
    14·1 answer
  • Consider the following method intended to modify the parameter names by removing all instances of the String n.
    14·1 answer
  • When TCP/IP translates a network layer address into a data link layer address, it sends a special ____________ to all computers
    15·2 answers
  • Wendy is an attacker who recently gained access to a vulnerable web server running Microsoft Windows. What command can she use t
    9·1 answer
  • Your company is developing a new marketing campaign and wants to know which customers have never placed an order. You will need
    10·1 answer
  • Using the college registration example from section 6.7.3 as a starting point, do the following:
    14·1 answer
  • 1.erros can easily be ____ 2.work is done in an ____ no mess environment 3.colors do not _____ and brushes are never ______ 4.st
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!